Swift代码库之分页UI部分基础代码
实现分类
- 新建浏览全部swift,VisitAllVC
- 尝试完成tableview的基础显示
代码
import UIKit
class VisitAllVC: UIViewController,UITableViewDataSource,UITableViewDelegate {
var wordDB:RFWordDB?
var wordList:[FRWord] = []
var imageDB:KFImageDB?
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
wordDB = MyManager.sharedInstance.wordDB
wordList = wordDB!.readDataByDic(searchDic:["康","熙","字","典","查","汉"])
imageDB = MyManager.sharedInstance.imageDB
self.navigationItem.title = "汉字查询"
}
//mark- tableview
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 110
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let oneWord = wordList[indexPath.row]
let dvc=WDetailVC(wordItem: oneWord)
self.navigationController?.pushViewController(dvc, animated: true)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return wordList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "VisitWordCell", for: indexPath) as! WordCell
let oneWord = wordList[indexPath.row]
//cell.wName.text=checkSub(mStr: oneWord.wNameStr, sStr: "<PUA>")
cell.wImage.image = imageDB?.readData(tupian: oneWord.wImageStr)
//cell.wPinYin.text = "拼音:"+oneWord.wPinYin
//cell.wBushou.text = "部首:"+oneWord.wBushou
//cell.wZBihua.text = "笔画:"+String(oneWord.wZBihua)
cell.wXuhao.text = "序号:"+String(oneWord.wXuhao)
return cell
}
func checkSub(mStr : String,sStr : String) -> String {
if (mStr.contains(sStr))
{
return ""
}
else
{
return mStr
}
}
//makr
}
网友评论