在iOS中使用多个故事板 [英] Using Multiple Storyboards in iOS

查看:218
本文介绍了在iOS中使用多个故事板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是创建一个选项卡式应用程序,然后每个选项卡的视图都在不同的故事板中构建。

My objective is to create a tabbed application, then the view for each of the tabs are constructed in separate storyboards.

我的主题板是标签视图。

My mainstoryboard is a tab view.

然后我创建了一个带有2个View Controller的辅助故事板(故事板#2)。第一个视图控制器(也标记为初始)有一个按钮,并且segue(模态)有第二个视图。

Then I create a secondary storyboard (storyboard#2) with 2 View Controllers. The first view controller (also ticked as initial) have a button, and segue (modal) to 2nd view.

我设法加载视图通过从故事板#2继承和覆盖loadView。

I managed to load the view by subclassing and overriding loadView from storyboard#2.

这是模拟器输出。

当点击点击我按钮时,我得到一个 EXC_BAD_ACCESS 。 segue不起作用,似乎第二个故事板没有被完全加载。

When click on the "click me" button, I get a EXC_BAD_ACCESS. The segue does not work, seems like the second storyboard is not being loaded completely.

有没有人试过这样做并让它运行起来?有来自SkillMaster.net的youtube视频,但他没有证明s​​egue是否在次要故事板下工作。视频在这里: http://youtu.be/D4_twoYvB4M

Has anyone tried to do this before and get it working? There's a youtube video from SkillMaster.net but he does not demonstrate if a segue is working under the secondary storyboard. the video is here: http://youtu.be/D4_twoYvB4M

感谢您的任何意见和帮助!

Thanks for any input and help!

屏幕截图:

  • http://www.box.com/s/njnyzjoqg8pnqofv838m
  • http://www.box.com/s/8dqygclmp5ic86e47bi5
  • http://www.box.com/s/k7foe7gpgh2rs3y8gqxd
  • http://www.box.com/s/rym111x7xqxqao51ruip

推荐答案

这些是我在多个故事板上看过的最好的文章。

These are the best articles I've seen on multiple storyboards.

  • Storyboard best practices
  • Linking storyboards with segues

这个人不仅告诉你如何在代码中创建一个新的故事板,他

Not only does this guy tell you how to create a new storyboard in code, he


  • 在实践中推荐多个故事板(更多模块化代码)

  • 讨论何时使用xibs与故事板(xibs)保持视图,storboards基于控制器)

  • 提供了一个用于链接故事板与segues的类在github上

  • recommends multiple storyboards in practice (more modular code)
  • discusses when to use xibs vs storyboards (xibs hold views, storboards are based on controllers)
  • provides a class for linking storyboards with segues on github

请注意,最后一点很重要,因为多个故事板的关键缺点是你通常不能用segue链接它们,但是robs库允许带有一点捏造

Note that this last point is important because the key downside of multiple storyboards is that you can't usually link them with segues, but robs library allows that with a bit of fudging

另见这里

这篇关于在iOS中使用多个故事板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆