很抱歉在这里问这种简单的问题。
但是我是 iOS 开发新手:(我也尝试在 google 上寻找答案,但我不明白。
我的问题是创建整个TableView后调用UITableView
的哪个协议(protocol)方法?
我的意思是当创建UITableView
然后调用UITableViewDataSource
方法,例如,
配置表格 View
– tableView:cellForRowAtIndexPath: required method
– numberOfSectionsInTableView:
– tableView:numberOfRowsInSection: required method
– sectionIndexTitlesForTableView:
– tableView:sectionForSectionIndexTitle:atIndex:
– tableView:titleForHeaderInSection:
– tableView:titleForFooterInSection:
等等...
但是我想知道在创建整个 TableView 后 UITableView 调用哪个方法(或调用上面的方法)而没有任何 UITableView 交互?
所以,请帮助我
最佳答案
由于 Apple 文档中未指定顺序,因此您不能安全地假设它们始终会以相同的顺序调用,并且在实现中做出此类假设通常不是一个好主意。
例如,不会为所有行调用 cellForRowAtIndexPath。它仅针对可见行调用,然后在用户滚动到其他行时调用。旧行在离开屏幕时也会被销毁,如果用户向上滚动,它将再次请求单元格。
但一般来说我们可以假设一些调用顺序:
– numberOfSectionsInTableView: (...Optional method...)
– sectionIndexTitlesForTableView: (...Optional method...)
– tableView:titleForHeaderInSection: (...Optional method...)
– tableView:titleForFooterInSection: (...Optional method...)
– tableView:numberOfRowsInSection: (...Compulsory method...)
– tableView:cellForRowAtIndexPath: (...Compulsory method...)
关于iphone - 创建UITableView后调用哪个协议(protocol)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12576860/