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

查看:22
本文介绍了在 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 个视图控制器的辅助故事板 (storyboard#2).第一个视图控制器(也打勾为初始)有一个按钮,和转场(模态)到第二个视图.

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.

我设法通过子类化和覆盖 storyboard#2 中的 loadView 来加载视图.

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

这是模拟器输出.

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

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 视频,但他没有演示 segue 是否在辅助故事板下工作.视频在这里: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!

截图:

推荐答案

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

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

这个家伙不仅告诉你如何用代码创建一个新的故事板,他

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

  • 在实践中推荐多个故事板(更模块化的代码)
  • 讨论何时使用 xibs 与故事板(xibs 持有视图,storboards 基于控制器)
  • 提供了一个用于将故事板与 segue 链接起来的类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天全站免登陆