A home button in iOS 5, xcode 4.2, Story board

2019-03-04 05:53发布

问题:

iOS 5.0, xCode 4.2

I am doing a multistep questionnaire.

There are about 10 questions on each branch, and there are sub branches. But the logic is fairly linear. Mostly Yes/no answers, but some multi choice options. The questionnaire will come to a conclusion page.

On this conclusion page, I would like to have a button that says HOME which takes the user to a specific start page so they can start again.

The problem is that I want the navigation controller stack to be cleared so the back buttons will not loop through the past selections.

Put another way, I want to clear out all of the view controllers on the navigation stack. Is there a simple way to do this?

回答1:

popToRootViewControllerAnimated: on UINavigationController will clear out the stack and return you to the root controller.



回答2:

You can set the viewControllers property of UINavigationController. This can even be done animated.