Here’s my code:
- (IBAction)play {
if (!self.mapViewController)
{
self.mapViewController = [[MapViewController alloc]initWithNibName:@"MapViewController" bundle:nil];
}
[self.navigationController pushViewController:mapViewController animated:YES];
}
What happen is: when I pressed the play button for the first time, new view doesn’t show up. When I pressed again, it crashes because the same UIViewController have been added into the stack more than once. Does anyone know how to fix this?
Edit:
Thank you for all of your answers. I checked the xib and I’ve found that I messed up the links. Fixed it 🙂
Ok try this below code this is worked for me:
if current viewcontroller is not uinavigation controller try this code:
(or) if currentviewcontroller is uinavigation controller try below code:
Thanks..!