我正在尝试将UITableViewCell选择引导到另一个viewController,同时向其传送数据。但是,它最终会推向一个零视图控制器
在Main.storyboard中,我创建了视图控制器,并为其提供了类#34; DetailedTweetViewController"
http://postimg.org/image/hf7wg0ilp/ - 显示类和标识符的图像
http://postimg.org/image/f0w0ezjzv/ - 图片显示没有segues
一切似乎都很好,所有这些都是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *currentTweet = _userPosts[indexPath.row];
DetailedTweetViewController *tweetDetailedViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailedTweetStoryboard"];
tweetDetailedViewController.statusID = currentTweet[@"id"];
[self.navigationController pushViewController:tweetDetailedViewController animated:YES];
}
我不知道为什么它不起作用......
这是错误的图片:http://postimg.org/image/cjb595s8j/
我尝试直接推送到视图控制器而不传递数据:
DetailedTweetViewController *detailedViewController = [[DetailedTweetViewController alloc]init];
[self.navigationController pushViewController:detailedViewController animated:YES];
但我没有任何错误只是一个空白屏幕:http://postimg.org/image/7i02wst9v/
在名为didSelectRowAtIndexPath
的另一个viewController中初始化了viewController
的当前视图控制器
这是代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
FeedViewController *feedViewController = [[FeedViewController alloc]init];
feedViewController.currentUserAccount = [_twitterAccounts objectAtIndex:indexPath.row];
feedViewController.navigationItem.hidesBackButton = YES;
[self.navigationController pushViewController:feedViewController animated:YES];
}
答案 0 :(得分:4)
获取这样的故事板而不是self.storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];// Find name of storyboard in your project plist
DetailedTweetViewController *tweetDetailedViewController = [storyboard instantiateViewControllerWithIdentifier:@"DetailedTweetStoryboard"];
答案 1 :(得分:0)
您还需要从故事板中初始化“feedViewController”
你不能使用self.storyboard初始化viewController,除非你已经从故事板初始化了你调用self.storyboard的视图。
例如 从中初始化detailedTweetViewController feedViewController通过storyboard ...然后feedViewController也必须已经从storyboard初始化