ios 获取最后一个cell_在UITableview部分中获取最后一个单元格
I have a section in UITableView which has multiple rows. I wish to get the last row or the last cell of the section to add a disclosure indicator on it.One way I am thinking to use is:NSIndexPath *las
I have a section in UITableView which has multiple rows. I wish to get the last row or the last cell of the section to add a disclosure indicator on it.
One way I am thinking to use is:
NSIndexPath *lastCellIndexPath = [NSIndexPath indexPathForItem:[self.tableView numberOfRowsInSection:2]-1 inSection:2];
Is there any other best way to get the cell or indexpath of the last cell on a section?
解决方案NSInteger totalRow = [tableView numberOfRowsInSection:indexPath.section];//first get total rows in that section by current indexPath.
if(indexPath.row == totalRow -1){
//this is the last row in section.
}
hope it helps.
I did this in tableView:willDisplayCell:forRowAtIndexPath: method
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
更多推荐
所有评论(0)