xcode segue jump management in a app with many views

空扰寡人 提交于 2019-12-13 03:09:22

问题


I have seven views that I need to navigate between from any of the other views. I don't want to keep doing segues from each one as new instances would keep being created...among other issues. What I was originally trying to do was have all the segues start from a home view and then go to the designated target view. When the user left that target view a public variable would be set if they wanted to go to any other view other than the home view. When the home view reappeared, it would check that public variable to see if another jump was needed. In the Home view I put the segue jump check in the -(void)viewDidAppear:(BOOL)animated function. The problem with this being you see the home screen for a second before it goes off to the new target view. The -(void)viewWillAppear:(BOOL)animated does not work for segues. I guess this is because it hasn't fully released the old segue yet?

Is there a better way to handle a freeform many view navigation issue like this? If anyone needs it, I can post some sample code for what I was trying to do. Thanks in advance for any help.


回答1:


It sounds like you need a UITabBarController.

It allows you to have multiple view controllers, and switch between them by tapping the tab on the bottom of the screen.

It allows you to have only one instance of each controller, so that as you switch between them, data persists and you aren't creating new instances each time.

Here is an example of what one looks like (notice the tabs at the bottom of the screen):


(source: xamarin.com)



来源:https://stackoverflow.com/questions/14099002/xcode-segue-jump-management-in-a-app-with-many-views

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