简体   繁体   中英

StoryBoard Navigate to Root View Controller

This is my first time using story board and I've set up like 5 view controllers with UINavigationController with buttons that push to the next view controller..

So I start on VC1 and push to VC2, then click and button and push to VC3, then click a button and push to VC4, and so on... on the last screen (VC5) I have a "home" button that the user can click to go back to the home screen (VC1), I've set it up so it pushes to VC1, the problem is when the user clicks that they are taken to the homescreen but then there is a back button on the navigation bar and they can go back to the last screen? After they click home they should not be able to return to previous screens without navigating through to them like they had the first time!

How can I accomplish this? Thanks! I'm used to working with xib and programmatically controlling the UINavigationControllers so this StoryBoard stuff is very new to me haha!

It sounds like you want an unwind segue. On the VC1 .m file add the following blank method:

 - (IBAction)unwindToVC1:(UIStoryboardSegue*)sender
 {
 }

Then in your storyboard on VC5 Ctrl-drag from your home button to the green Exit button at the bottom of your view controller. Choose the unwindToMainMenu option and it should now go back to the VC1 when pressed and no longer have the back button as it has popped all the view controllers.

我认为您正在寻找的方法是popToRootViewControllerAnimated:

[self.navigationController popToRootViewControllerAnimated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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