【发布时间】:2013-12-30 19:04:25
【问题描述】:
我试图在选择导致另一个 viewController 时创建一个 UITableViewCell,同时将数据传输到它。然而,它最终只是推送到一个 nil 视图控制器
在 Main.storyboard 中,我创建了视图控制器并为它指定了“DetailedTweetViewController”类
http://postimg.org/image/hf7wg0ilp/ - 显示类和标识符的图像
http://postimg.org/image/f0w0ezjzv/ - 图片显示没有转场
一切似乎都很好,这是我的代码:
- (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/
更新
在另一个名为 viewController 的 viewController 中初始化具有 didSelectRowAtIndexPath 的当前视图控制器
这是代码:
- (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];
}
【问题讨论】:
-
您可以记录
self.storyboard和tweetDetailedViewController以检查它们的空值吗? -
它是
(null)但为什么... -
self.storyboard或tweetDetailedViewController是哪一个 -
好的,你是如何初始化当前视图控制器的?有
didSelectRowAtIndexPath方法的那个? ...代码? -
@HaniIbrahim 我更新了问题...
标签: ios xcode uitableview xcode5