iphone - 创建UITableView后调用哪个协议(protocol)方法

标签 iphone objective-c ios uitableview

很抱歉在这里问这种简单的问题。

但是我是 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/

相关文章:

ios - 如何使用目标使用相同的代码库启动多个应用程序?

iphone - 手机间隙 : get the filesize of captured audio file

iphone - iOS:网络应用的最佳实践

ios - 更改 UICollectionViewCell 中的标签位置

ios - NSUUID 到 NSString

iphone - 如何在 iOS4 中发布图片

ios - 如何使用 AVCaptureDevice 保存图像

ios - 我通过协议(protocol)将数据从 UITableViewController 传递到 UIViewController,而不是 int 值,我得到的是 nil。为什么?

ios - 如何使用 phonegap for ios 在弹出窗口中打开 PDF 文件

javascript - 在 Objective C 中执行 js