如何通过特定的UITableViewCell获取原始的indexPath.section?
- (NSString *)sectionForCell:(UITableViewCell *)cell {
//How to get the original indexPath.section by the specific UITableViewCell?
}
答案 0 :(得分:6)
UITableView有一个方法可以为您提供特定单元格的索引路径:
NSIndexPath *path = [self.tableView indexPathForCell:cell];
return path.section;
请注意,这将返回一个整数,而不是一个字符串。
答案 1 :(得分:2)
使用UITableView实例方法:
- (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell