在没有UINavigationController的情况下链接Storyboard

时间:2013-10-28 15:08:31

标签: uinavigationcontroller ios7 uistoryboard

我有一个iOS 6应用程序,我正在更新以使用iOS 7并使其使用故事板。我正在尝试使用多个故事板,以便我可以将我的项目分解为应用程序中每个屏幕的模块。到目前为止,这已经很好了但现在我需要提供一种在各种故事板之间导航的方法,同时仍然像在iOS 6中那样进行工作(但是使用更新的艺术作品)。

我不在我现有的iOS 6应用程序中使用UINavigationController,我不想使用它,因为到目前为止我已经能够在UIButton点击手势上使用代码在XIB之间来回导航。 UINavigationController无法轻松定制导航按钮的内容,从目前为止我所掌握的内容来看。

通过将故事板的名称作为属性传递,我发现这种在不同故事板https://github.com/rob-brown/RBStoryboardLink上的视图控制器之间移动的方式非常简洁。

但它似乎只在使用UINavigationController时起作用。我收到一个错误“Push segues只能在没有UINavigationController的情况下由UINavigationController实例管理源控制器时使用。

有没有办法在故事板之间导航,只使用上面的RBStoryboardlink但不需要UINavigationController?

1 个答案:

答案 0 :(得分:1)

Push segues can only be used when the source controller is managed by an instance of UINavigationController

这意味着您尝试将视图控制器推送到源,而源没有任何导航控制器堆栈。在这种情况下,您应该尝试将实例化视图控制器的视图作为子视图添加到源视图控制器的视图中。

 UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
 UIViewController *viewController = [mainStoryboard instantiateInitialViewController];
 [self.view addSubview:viewController.view];

或者你模态地呈现,这纯粹取决于你的要求。

 UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
 UIViewController *viewController = [mainStoryboard instantiateInitialViewController];
 tabBarViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
 [self presentViewController:tabBarViewController animated:NO completion:NULL];
相关问题