views:

100

answers:

3

Hi,

I am developing an application in which I am using a login form at first screen. If the user is new he is takne to the signup form and after that he is also taken to the home page as a normal user.

Now my question is "If the new user presses back btn, how can I direct him back to the login page and not to the sign-up forms and all in between?"

Should I change the navigationcontroller's viewControllers array?

+2  A: 

UIViewController has some methods for this. You can use

- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated

to pop up to the top view controller, or

- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated

to keep popping until you get to a specific controller you know is on the stack somewhere...

David Maymudes
+2  A: 

- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated on UINavigationController will pop the user back to the last view controller in the stack.

If you want to get the navigation stack to a new known state you can use - (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated the last item in the array will then be the active one.

monowerker
+1  A: 

Perhaps you should think about your problem from another angle.

The signup form isn't really part of the flow of things--it's a temporary, one-time, mandatory interjection.

If you made the signup form a modal view, then you could just dismiss the modal view when signup is complete (or cancelled) and move normally to the next view controller.

That way, when you back up, the login view is the immediately previous one.

Gorm