0
我有一些简单的代码:在tableView中调用函数numberOfSections多少次?
class TestTableViewController: UITableViewController {
override func numberOfSections(in tableView: UITableView) -> Int {
print("toto")
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
cell.textLabel?.text = "Hello world"
return cell
}
}
我在想,功能numberOfSections
被称为只有一次,当的tableView是加载或当我们要求重装。
但在我的控制台与此代码我有6“托托”。
有人可以向我解释什么时候他们进入功能numberOfSections
?
可能重复[什么时候tableView:numberOfRowsInSection:在UITableView中调用?](http://stackoverflow.com/questions/16914020/when- is-tableviewnumberofrowsinsection-called-in-uitableview) – ozgur