I want that when you click on the toSecond button the transition disappears, and the backBtn2First button works back, but nothing works. That is, the transition is working but not the UIViewAnimationTransitionCurlUp in any way. Such a feeling that backBtn2First is simply ignored. How to make it work correctly?

-(IBAction) backBtn2First //для обратного перехода { FirstViewController *fvc = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:1.0]; [self.navigationController pushViewController:fvc animated:NO]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO]; [UIView commitAnimations]; } -(IBAction)toSecond { SecondViewController *svc = [[SecondViewController alloc]initWithNibName:@"InfoViewController" bundle:nil]; UIBarButtonItem *backBtn2 = [[UIBarButtonItem alloc]initWithTitle:@"try back" style:UIBarButtonItemStyleBordered target:self action:@selector(backBtn2First)]; [[self navigationItem]setBackBarButtonItem:backBtn2]; [self.navigationController pushViewController:svc animated:YES]; } 
  • What I see in the code of the backBtn2First method does not lead back to navigation, it creates a new screen and pushes it onto the stack with the screen, which is clearly not what I wanted, right? - iFreeman

1 answer 1

In the backBtn2First method, replace all code with:

[self.navigationController popViewControllerAnimated: YES];

It will return the navigationController to the previous controller. It is also desirable to transfer this method and the creation of the backBtn2 button to the SecondViewController class.