Repeatedly pressing the view controller is not supported?

I get the following error when I try to switch views like this:

-(void)changeView1ToView4 { [self.navigationController1 pushViewController:view4 animated:YES]; } 

This does not happen when the application loads, and the user goes directly to this view. This failure occurs only when I go to one of my other views, return to the main menu, and then try to go to this view.

Also, if you were not sure already, I use the UINavigationController. Also, this code is in the application delegate, and I call it from the view controller, which has a parent view, so I use the. Link to call it like this:

 [self.reference changeView1ToView4]; 

Is there any real way to fix this?

Thanks!

Edit1:

 [self.navigationController1 pushViewController:view4 animated:NO]; [self.navigationController1 pushViewController:view4 animated:YES]; I tried that and got this crash message in the console: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported (<View2: 0x18d540>)' 
+4
source share
4 answers

When 2 stack views are pressed, try calling:

 [self.navigationController1 pushViewController:view4 animated:YES]; 

and

 [self.navigationController1 pushViewController://secondviewcontrollername// animated:NO]; 

If you try to click more than one view with an animated field that is set to YES, you confuse the stack. Only animate one view at a time.

+8
source

just FYI if you call setViewControllers: animated: there is no need to call pushViewController: afterwards, otherwise you will get a "failure of the same instance of the dispatcher manager more than once."

+4
source
  @try { [self.navController pushViewController:viewController animated:NO]; } @catch (NSException * e) { NSLog(@"Exception: %@", e); [self.navigationController popToViewController:viewController animated:NO]; } @finally { //NSLog(@"finally"); } 
0
source

Check this condition before pressing

 if (![[self.navigationController topViewController] isKindOfClass:[YOURCONTROLLER class]]) [self.navigationController pushViewController:YOURCONTROLLER animated:YES]; 
0
source

All Articles