Best way to use multiple storyboards in app

老子叫甜甜 提交于 2019-12-06 12:33:15
  1. Do not change the root view controller. There is no need. An app should have one root view controller for the entire lifetime of the app. If you want to completely replace the interface with a view controller's view, present that view controller. A presented view controller can appear and just stay there for the rest of the lifetime of the app. (Actually, if the login interface is the rarer interface, it would make more sense to make the main interface the main interface and present the login interface on top of it.)

  2. By the same token, there is no need to use both a login storyboard and a main storyboard. Those sets of interface can be in the same storyboard, so that there is no need to load a new storyboard.

I tend to modally present login VCs. I always load the main VC. If no session token exists then I modally present the login VC without animation. Effectively this makes it appear as if the login view was present on startup. Once the user successfully logs in you can dismiss with the typical modal dismiss (fall off the bottom of the screen) or do something like a cross-fade.

For storyboards, I personally use multiple. If you have a non-trivial app the number of views in an SB can grow quite large. It can be difficult to manage - finding the one you want in the sea of views is annoying and time consuming. Further, it bogs my machine down horribly. Perhaps most importantly, if you are working on a team with source control (which you absolutely should be using) - it is really annoying to try to manage access to the one monolithic SB. Generally it isn't possible to merge changes if multiple devs modify a single SB. At least with multiple you can assign different people to different tasks which are each tied to their own SB. There's no performance advantage to having multiple SBs (only the instantiated views occupy memory). But there are advantages from a development efficiency point of view.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!