首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >转到另一个故事板?

转到另一个故事板?
EN

Stack Overflow用户
提问于 2012-03-06 07:28:45
回答 5查看 53.9K关注 0票数 136

是否可以从一个故事板分割到另一个故事板,或者将一个故事板嵌入到另一个故事板的视图控制器中?我需要在UINavigationController中放置一个UITabBarController,并且我想让它们保持良好和分离。

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2012-03-08 07:50:54

是的,但是你必须以编程的方式来完成:

代码语言:javascript
复制
// Get the storyboard named secondStoryBoard from the main bundle:
UIStoryboard *secondStoryBoard = [UIStoryboard storyboardWithName:@"secondStoryBoard" bundle:nil];

// Load the initial view controller from the storyboard.
// Set this by selecting 'Is Initial View Controller' on the appropriate view controller in the storyboard.
UIViewController *theInitialViewController = [secondStoryBoard instantiateInitialViewController];
//
// **OR**  
//
// Load the view controller with the identifier string myTabBar
// Change UIViewController to the appropriate class
UIViewController *theTabBar = (UIViewController *)[secondStoryBoard instantiateViewControllerWithIdentifier:@"myTabBar"];

// Then push the new view controller in the usual way:
[self.navigationController pushViewController:theTabBar animated:YES];
票数 202
EN

Stack Overflow用户

发布于 2015-11-17 17:21:20

从Xcode 7开始,您可以使用Storyboard引用以图形方式完成此操作:

将情节提要引用添加到情节提要。在ViewController和故事板引用之间创建分段(按住Ctrl键并拖动)

然后填写这些字段。

其中"Tutorial“是"Tutorial.storyboard”文件,"MainTutorialController“是ViewControllerSettings中的"Storyboard ID”字段

票数 125
EN

Stack Overflow用户

发布于 2012-03-12 06:31:47

你不能手动处理segues,因为UIStoryboardSegue是一个抽象类。您需要将其子类化并实现perform,这样它才能执行任何操作。它们实际上是在故事板中创建的。不过,您可以手动推送视图控制器,这是一个很好的解决方案。lnafziger的答案做得很好:

代码语言:javascript
复制
UIStoryboard *secondStoryBoard = [UIStoryboard storyboardWithName:@"secondStoryBoard" bundle:nil];
UIViewController *theTabBar = [secondStoryBoard instantiateViewControllerWithIdentifier:@"myTabBar"];
[self.navigationController pushViewController:theTabBar animated:YES];

不过,有一件事需要注意,你说过你想让事情保持良好和独立。故事板的想法是让你在一个地方做所有的设计工作的同时,保持事物的分离。每个视图控制器都很好,并且在故事板中与其他控制器分开。整个想法就是把所有的东西都放在一个地方。只要把它布置好,这样它就有条理了,你就可以行动了。除非你有一个非常好的理由,否则你不应该把它分开。

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9575702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档