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