在controller中delegate了UITableViewDataSource以后,是必须实现这个方法以展示UITableView的。它的方法原型如下
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
能否结合例子具体解释下NSIndexPath的含义,另外与它想对应的还有一个必须实现的方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
这个section表示的又是什么呢?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
1、
NSIndexPath主要包含(NSUInteger)section和(NSUInteger)row,每个row必然是属于一个section的,否则这个row没有意义,- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section里面就是表明各section有多少row。2、打开
Contacts,里面的那些A、B、C...这样的标题就属于section header,header + rows + footer就构成了一个完整的section. 可以通过- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;进行定制header,footer类似