我试图通过一个不声明indexPath的方法访问tableView的NSIndexPath。
这就是我想要做的:
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index {
switch (index) {
case 0:
{
NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
DetailScheduleViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
svc.title = [[news objectAtIndex:tempIndexPath.row]objectForKey:@"Series"];
svc.newsArticle = [news objectAtIndex:tempIndexPath.row];
[self.navigationController pushViewController:svc animated:YES];
[cell hideUtilityButtonsAnimated:YES];
break;
}
default:
break;
}
}当然,这里的问题是:
NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];indexPathForRow为0,它将只返回第一个单元格项。这不是我想要的。我希望能够在indexPath中返回整个列表。我该怎么做?
发布于 2014-02-15 20:15:55
您应该向tableView请求这样的indexPath:
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index
{
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
}https://stackoverflow.com/questions/21802989
复制相似问题