rwvaldivia
rwvaldivia

Reputation: 395

How back two UIViewController

My application has four steps (View1, View2, and finally View3 View4) in which the user must pass before finalizing the process. At the end there is a back button. However when I click back the app sends the user to View3 (At this point he is in View4).

The problem is how to return to View1 with a simple click the back button?

I have two views that inherit from UIViewController and the other two that inherit UITableViewController

To create a new view I use the code above:

SelectSubOptionsViewController * selectSubOpt; selectSubOpt = [[ SelectSubOptionsViewController alloc] initWithNibName:@"SelectSubOptionsViewController" bundle:nil] [UIView beginAnimations:@"flipping view" context:nil]; [UIView setAnimationDuration:1]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

[self.view addSubview: selectSubOpt.view];

And to remove a view I use the code above:

-(IBAction) btnBack:(id) sender {

[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition: UIViewAnimationTransitionCurlUp
                       forView:self.view.superview cache:YES];

[self.view removeFromSuperview];
[UIView commitAnimations];

}

Tanks a lot for any answer...

Upvotes: 0

Views: 188

Answers (1)

Alan Moore
Alan Moore

Reputation: 6575

You could use a UINavigationController to manage your screens -- do a push to put up each view, then do a pop to root controller to get back to the beginning. I think it is more suited to your task here.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

Upvotes: 1

Related Questions