如何获取特定UITableViewCell的节号?

Leo*_*ang 2 objective-c uikit ios4 ios

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

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

jrt*_*ton 6

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

NSIndexPath *path = [self.tableView indexPathForCell:cell];
return path.section;
Run Code Online (Sandbox Code Playgroud)

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