【发布时间】:2020-07-18 08:13:38
【问题描述】:
我不明白为什么我的单元格没有显示,即使我有正确的标识符和类
class homeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print("p")
let cell: homeTableViewCell = tableView.dequeueReusableCell(withIdentifier: "homeTableViewCell", for: indexPath) as! homeTableViewCell
return cell
}
}
表格视图单元格和此处的标识符相同
【问题讨论】:
-
这些函数都被调用了吗?
-
添加断点进行测试
-
你设置数据源了吗?
-
是的,我确实设置了数据源
-
` 类 homeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { `
标签: ios swift uitableview cell