首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从方法访问NSIndexPath

从方法访问NSIndexPath
EN

Stack Overflow用户
提问于 2014-02-15 20:10:09
回答 1查看 384关注 0票数 0

我试图通过一个不声明indexPath的方法访问tableView的NSIndexPath。

这就是我想要做的:

代码语言:javascript
复制
- (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;
    }
}

当然,这里的问题是:

代码语言:javascript
复制
        NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];

indexPathForRow为0,它将只返回第一个单元格项。这不是我想要的。我希望能够在indexPath中返回整个列表。我该怎么做?

  • 如果你们需要更多的澄清请告诉我。谢谢!
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-15 20:15:55

您应该向tableView请求这样的indexPath:

代码语言:javascript
复制
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index
{
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21802989

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档