objective-c - UITableViewDataSource中的cellForRowAtIndexPath如何实现?
高洛峰
高洛峰 2017-04-21 10:58:06
[iOS讨论组]

在controller中delegate了UITableViewDataSource以后,是必须实现这个方法以展示UITableView的。它的方法原型如下

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

能否结合例子具体解释下NSIndexPath的含义,另外与它想对应的还有一个必须实现的方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

这个section表示的又是什么呢?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回复(1)
PHP中文网

1、NSIndexPath主要包含(NSUInteger)section(NSUInteger)row,每个row必然是属于一个section的,否则这个row没有意义,- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section里面就是表明各section有多少row
2、打开Contacts,里面的那些A、B、C...这样的标题就属于section headerheader + rows + footer就构成了一个完整的section. 可以通过- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;进行定制header,footer类似

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号