【问题标题】:Implementing tableView didSelectRowAtIndexPath in storyboard在情节提要中实现 tableView didSelectRowAtIndexPath
【发布时间】:2014-02-14 03:05:30
【问题描述】:

您将如何在情节提要中实现 tableView didSelectRowAtIndexPath。我已经创建了一个创建表的视图控制器。当单击表格中的每个单元格时,我不知道在情节提要中如何使视图转换。

这是我最初以编程方式在该方法中的内容:

Show *show = [self.shows objectAtIndex:indexPath.section];
ShowContentItem *showItem = show.showContentItems[indexPath.row];

if ([showItem.contentType isEqualToString:@"Headline_Section"]) {
    HeadlinesViewController *headlinesVC = [[HeadlinesViewController alloc] init];
    headlinesVC.shows = [[NSMutableArray alloc] initWithObjects:show, nil];
    [self.navigationController pushViewController:headlinesVC animated:YES];
} else {
    NSInteger contentIndex = [self.storyPostContent indexOfObject:showItem];
    NSRange rangeForView = NSMakeRange(contentIndex, [self.storyPostContent count] - contentIndex );

    ShowContentViewController *showContentVC = [[ShowContentViewController alloc] init];
    showContentVC.contentList = [self.storyPostContent subarrayWithRange: rangeForView];

    [self.navigationController pushViewController: showContentVC animated:YES];
}

我将如何专门更改上面的代码以使用情节提要?

【问题讨论】:

  • 在您的故事板中,您将表格配置为静态填充还是动态填充?
  • 动态填充。
  • 您是否配置了一个类以符合UITableViewDelegate 协议,并将表的委托属性链接到该类?
  • 是的,我已经完成了。

标签: ios user-interface storyboard


【解决方案1】:

您可以控制从原型单元到目标控制器的拖动。然后在prepareForSegue 你做这样的事情:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"yourSegue"]) {
        yourViewController *destinationController = segue.destinationViewController;
        destinationController.someVariable = yourTable.indexPathForSelectedRow;
    }

}

【讨论】:

  • 我需要在情节提要中添加转场吗?如果是这样,是什么?
  • 从原型单元到目标视图控制器。
  • 我还需要 didSelectRowAtIndexPath 吗?
  • 不,如果您使用 segues,则不会。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多