[英]Implementing tableView didSelectRowAtIndexPath in storyboard
您將如何在情節提要中實現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;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.