如何获取特定UITableViewCell的节号?

时间:2012-02-25 15:24:24

标签: objective-c ios ios4 uikit

如何通过特定的UITableViewCell获取原始的indexPath.section?

- (NSString *)sectionForCell:(UITableViewCell *)cell {
   //How to get the original indexPath.section by the specific UITableViewCell?
}

2 个答案:

答案 0 :(得分:6)

UITableView有一个方法可以为您提供特定单元格的索引路径:

NSIndexPath *path = [self.tableView indexPathForCell:cell];
return path.section;

请注意,这将返回一个整数,而不是一个字符串。

答案 1 :(得分:2)

使用UITableView实例方法:

- (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell