我嘗試使用下面的代碼返回行的表中的次數:「未能獲得細胞」錯誤試圖使用一個UITableView
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let count = FirstTableArray.count
print(count)//prints 5
return count
}
它不會工作給予以下錯誤
2016年11月20日13:28:46.787 ModularProject [10870:2357799] *斷言故障 - [UITableView的_configureCellForDisplay:forIndexPath:],/BuildRoot/Library/Caches/com.apple.xbs/Sources /UIKit_Sim/UIKit-3600.5.2/UITableView.m:8035 2016-11-20 13:28:46.829 ModularProject [10870:2357 799] *由於未捕獲的異常'NSInternalInconsistencyException',原因:'UITableView(; layer =; contentOffset:{0,-64}; contentSize:{375,44}>)無法從其dataSource()中獲取單元格'
我無法理解爲什麼強制0作爲返回變量的作用而不是1?
編輯1:
這裏是我的參考
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print("runs")
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
print("runs2")
cell.textLabel?.text = "Foo"
return cell
print("runs3")
}
你執行的cellForRowAtIndexPath? – Adeel
是的,我做了以後 –
後你發生了什麼實現它? – Adeel