xcode segue jump management in a app with many vie

2019-08-22 15:52发布

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条回答
乱世女痞
2楼-- · 2019-08-22 16:34

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):

http://docs.xamarin.com/@api/deki/files/866/=Picture_1.png

查看更多
登录 后发表回答