您将如何在情节提要中实现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];
}


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

最佳答案

您可以控制从原型单元到目标控制器的拖动。然后在prepareForSegue中执行以下操作:

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

}

10-08 17:21