Question

That's what I'm trying to do: I have a navigationController based app and many different views. Let's say that on the third view, I want to view the view 4 using UIModalTransitionStyleCoverVertical. That I have done it using this code:

-(void)changeView4{
    View4 *screen = [[View4 alloc]initWithNibName:nil bundle:nil];
    screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:screen animated:YES];    
}

On the view 4 I have a button to return back to the view 3, but the problem is that when I press it, the View3 doesn't show the navigation controller, so i can't return to the view 2. Can somebody help me? thanks.

Était-ce utile?

La solution

When you "return" to your third view, you're not actually going back to the third view that you showed earlier; instead, you create a new third view, and present it over your fourth view. At that point, your view stack looks like this:

View 3 // don't want this!
View 4
View 3 // want to get back to here!
View 2
View 1

Instead of creating a new View3 instance, you should dismiss your existing fourth view using something like the following:

// Inside View4
- (IBAction)dismissView4:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

This should get you back to the third view that you had earlier, which should have the navigation bar showing with the appropriate back button.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top