【发布时间】:2012-10-09 12:51:06
【问题描述】:
我正在尝试将 Apple 的简单 Collection View 示例集成到一个项目中。
我有这个代码:
-(IBAction)buttonTapped:(id)sender {
NSLog(@"%s", __FUNCTION__);
ImageViewController *ivc = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:NULL] instantiateViewControllerWithIdentifier:@"images"];
NSLog(@"1");
[self.navigationController pushViewController:ivc animated:YES];
NSLog(@"2");
}
我看到了日志语句,但没有推送任何视图。我已将“图像”设置为情节提要 ID。这是我第一次使用 Storyboard,所以如果我做错了什么,我将不胜感激。
谢谢
【问题讨论】:
-
将
NSLog(@"1");替换为NSLog(@"DEBUG: ivc = %@", ivc);和NSLog(@"DEBUG: Nav Controller = %@", self.navigationController);。这将告诉您是哪一个导致了问题。 -
谢谢,有了这些信息,我想出了这个:-(IBAction)photoButtonTapped:(id)sender {UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"ImageStoryboard" bundle:nil]; ImageViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"ImageView"]; [自我presentViewController:ivc动画:是完成:无]; }
-
所以你的标识符是错误的?那解决了吗?
-
是的,它们不同步并且 navController 是空的。那会教我简单地复制代码:)
标签: uiviewcontroller storyboard ios6