![](/img/trans.png)
[英]uilabel from custom tableview cell is not displayed in tableviewcontroller
[英]Custom TableViewController tableView() method not called
这是我的自定义TableViewController
类。
我在viewDidLoad
和tableView
方法中插入了一条打印语句
viewDidLoad
已打印到控制台,但未显示tableView
我确保在属性编辑器中添加标识符Device Cell
,所以我不确定自己做错了什么
class MyTableViewController: UITableViewController {
// ... some code
override func viewDidLoad() {
super.viewDidLoad()
print("viewDidLoad")
}
// ... some code
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell =
tableView.dequeueReusableCell(
withIdentifier: "Device Cell", for: indexPath)
// Configure the cell...
print("tableView")
let device = mWifiDevices[indexPath.row]
cell.textLabel?.text = device.mIpAddress
return cell
}
// ... some code
}
h! 解决方案仅是添加行数和节数获取器的问题
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return mWifiDevices.count
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.