我的数据有50个条目。模拟器停在12点,我不明白。为什么模拟器只有12行?
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
funcSectCount += 1
let data = AppData.orgNames
print("data.count=", data.count, " func Section count=", funcSectCount)
return data.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
funcRowCount += 1
let data = AppData.orgNames
let cell = myTable.dequeueReusableCell(withIdentifier: "myCell", for:
indexPath)
cell.textLabel?.text = data[indexPath.row]
print("indexPath.row=", indexPath.row, " func Row count=", funcRowCount)
return cell
}
这作为用于每个功能的最终打印:
data.count = 50 FUNC区段数= 3(好奇,但次要)
indexPath.row = 11 FUNC 行count = 12
永远不要依赖于调用数据源和委托方法的次数和顺序。 – rmaddy