简体   繁体   English

Xcode中的情节提要

[英]Storyboard in Xcode

I've been working with Xcode for a while, and what I'm doing works, but I can't image that it is the best way to do it. 我使用Xcode已有一段时间了,我正在做的事情很有效,但是我无法想象这是最好的方法。 When I want to transition between scenes in Xcode, I create a segue between UIViewControllers in the main storyboard. 当我想在Xcode中的场景之间切换时,我在主故事板上的UIViewController之间创建了一个序列。 This is a picture of a storyboard in one of my apps. 这是我的一个应用程序中的情节提要的图片。 我的故事板

By looking at the picture, you can probably understand why I'm curious about whether or not what I'm doing is bad practice. 通过查看图片,您可能可以理解为什么我对自己的工作是否是不好的做法感到好奇。 What should I be doing to transition between scenes, or what do most people do to transition between scenes? 在场景之间过渡时我应该怎么做?或者大多数人在场景之间过渡时应该做什么? Thanks for the help! 谢谢您的帮助!

This is not easy to answer, but I will give you some context: 这不容易回答,但是我会给你一些背景:

  1. Storyboards can be a nice visual way to remove push/present code from the view controllers and make it clear what is happening (vs code). 故事板是从视图控制器中删除推送/呈现代码并弄清楚正在发生的事情(相对于代码)的一种不错的视觉方式。
  2. Having UIViewControllers handle navigation is not considered best practices (at least in many larger projects/enterprises). 让UIViewController处理导航被视为最佳实践(至少在许多大型项目/企业中)。 This is why patterns like VIPER (among other reasons, and yes VIPER can be overkill). 这就是为什么像VIPER这样的模式(还有其他原因,是的,VIPER可能会过大)。

In your case the relationship is not clear, many things also go back and forth. 就您而言,这种关系还不清楚,许多事情也会来回走动。 Now it might be possible you can lay them out better, and perhaps the containment or relationships can be tweaked. 现在,您可能可以将它们布置得更好,并且可以调整围堵或关系。

Here's some advice I can give. 这是我可以提供的一些建议。 Try to make view controllers as dumb as possible about opening other view controllers, both the what and how - they ideally should just indicate to some controller/mediator/manager they wish to "do" something. 尝试使视图控制器在打开其他视图控制器时尽可能愚蠢,无论是什么方式以及如何操作-理想情况下,它们仅应向某些控制器/介体/管理器指示它们希望“执行”操作。 It makes maintenance and refactoring a lot easier, especially adding a new feature later that might change how navigation works, such as adding on boarding into the app. 它使维护和重构变得容易得多,尤其是在以后添加可能会改变导航方式的新功能,例如在应用程序中添加登机功能。

Long story short, storyboards are not bad , however many enterprise and large projects do not use them both due to the difficulty in version control with multiple developers (using shallow storyboards with NIBs can mitigate this, you do lose some of the Segue), and because you can tend to grow overly complex view controllers. 长话短说,情节提要还不错 ,但是由于多个开发人员在版本控制方面存在困难,许多企业和大型项目都不使用它们(将浅情节提要与NIB一起使用可以减轻这种情况,您确实会损失一些Segue),并且因为您可能倾向于增长过于复杂的视图控制器。 Its great for personal, smaller apps... as complexity grows, value proposition becomes thinner. 它非常适合个人的小型应用程序……随着复杂性的增长,价值主张变得越来越薄。

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

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