0
我使用swift爲iPad創建iOS應用程序。每個視圖都會有表格視圖,我創建了UITableView
類,但我無法查看任何數據。我已經將其他視圖中的tableview鏈接到了該自定義類。iOS swift with tableview自定義類
import UIKit
class SideTable: UITableView, UITableViewDataSource, UITableViewDelegate {
var TableItems = ["...", "Dashboard"]
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func awakeFromNib() {
super.awakeFromNib()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return TableItems.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = dequeueReusableCell(withIdentifier: TableItems[indexPath.row])! as UITableViewCell
cell.textLabel?.text = TableItems[indexPath.row]
cell.textLabel?.numberOfLines = 0
cell.textLabel?.lineBreakMode = NSLineBreakMode.byWordWrapping
// let currentpagetitle = self.navigationItem.title?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
let cellname = cell.reuseIdentifier?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
// if (cellname == currentpagetitle)
// {
//
// cell.backgroundColor = UIColor.lightGray
// }
//
return cell
}