简体   繁体   English

使用storyboard或xib作为单视图控制器?

[英]Use storyboard or xib for single view controller?

I have to implement the layout of a single screen, which is not connected to the overall app flow, and I was wondering if it makes sense to use a Storyboard. 我必须实现单个屏幕的布局,它没有连接到整个应用程序流程,我想知道使用Storyboard是否有意义。

Storyboards make sense for flow/navigation (multiple controller), have some convenient features like, iirc prototype cells which are not available in xib. 故事板对流/导航(多控制器)有意义,有一些方便的功能,如xib中没有的iirc原型单元。 And it also makes sense if I think maybe later the screen may become a "story" (more view controllers). 如果我想以后可能会成为一个“故事”(更多视图控制器),这也是有道理的。 But none of this advantages are useful for my particular case. 但是这些优点对我的具体情况都没有用。

I was thinking anyways in using Storyboard, as it seems to be a bit more flexible than xib generally, but is there any disadvantage? 我一直在考虑使用Storyboard,因为它似乎比xib更灵活一点,但是有任何缺点吗? Maybe performance penalty or such? 也许性能损失还是这样? Is there a preferred way to setup single view controller? 有没有一种设置单视图控制器的首选方法?

Go ahead..take the advantages of using storyboard. 继续......利用故事板的优势。 There is no disadvantages or performance issues particular to storyboards when compared to xib files. 与xib文件相比,故事板没有特定的缺点或性能问题。 Its all about your convenience. 这完全取决于您的便利性。 As you said the single view controller may become a story in future, then the storyboard would be a right decision. 正如您所说,单视图控制器可能会成为未来的故事,那么故事板将是一个正确的决定。 And when to use xib? 什么时候使用xib? thats upto you, one ideal situation where i will choose xib is, if i have an independent controller that i want to share with other project also then i would choose xib. 这就是你,一个理想的情况,我会选择xib,如果我有一个独立的控制器,我想与其他项目共享,那么我会选择xib。

The performance penalty would only bother under the circumstance which too many controllers (more than 10) with segues were squeezed in one Storyboard. 性能损失只会在一个故事板中挤压过多控制器(超过10个)segue的情况下打扰。 Everything would be totally fine before that. 在那之前一切都会好起来的。

And if you have more than two people are trying to edit same storyboard file than you have to resolve conflict, which will be more tedious job. 如果你有两个以上的人试图编辑相同的故事板文件而不是你必须解决冲突,这将是更繁琐的工作。

Storyboard benefits: a. 故事板的好处:a。 easy demo purpose and fast implementation. 简单的演示目的和快速实施。 b. small team like two person. 小团队喜欢两个人​​。 c. C。 Storyboard is providing complete view and navigation model. 故事板提供完整的视图和导航模型。

XIB benefits: a. XIB的好处:a。 You can modularize your code. 您可以模块化您的代码。 b. More people can work on different-different controller without affecting your xib or code. 更多人可以在不同的控制器上工作,而不会影响您的xib或代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM