Using PushView controller and Popviewcontroller make the app crashes

399 views Asked by At

In My app, I am using push and pop view controller to navigate between UIViewControlers. I have an UIViewcontroller A and UIViewController B. When I click on a button in UIViewcontroller A and use the below code

UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController = [storybord instantiateViewControllerWithIdentifier:@"editmessage"];
[self.navigationController pushViewController:viewController animated:YES];

I am able to navigate to UIViewController B. In B, I have a cancel button upon clicking I need to come back to A. The code I am using is below

NSLog(@"You did it");
[self.navigationController popViewControllerAnimated:YES];
NSLog(@"You did it again");

When I press the button in UIViewcontroller A,I am able to navigate to UIViewcontroller B, the viewdidload method of B gets executed. But I am seeing the following message in log file.

2014-01-06 11:40:58.056 padua[5710:60b] View Did Load of editmesage controller
2014-01-06 11:40:58.231 padua[5710:60b] nested push animation can result in corrupted navigation bar
2014-01-06 11:40:58.633 padua[5710:60b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

When I press the cancel button, the viewdidload of B is again getting executed. I am not sure why this is happening and the app goes to a state where only a blank background image is displayed. Please find the log below. Please let me know where I am going wrong.

CODE

-(IBAction)cancelMessage:(id)sender{
NSLog(@"You did it");
[self.navigationController popViewControllerAnimated:YES];
NSLog(@"You did it again");

}

Logs

014-01-06 11:40:58.795 padua[5710:60b] Unbalanced calls to begin/end appearance transitions for <editMessageController: 0x1900d440>.
2014-01-06 11:41:04.683 padua[5710:60b] You did it
2014-01-06 11:41:04.708 padua[5710:60b] View Did Load of editmesage controller
2014-01-06 11:41:04.769 padua[5710:60b] You did it again
0

There are 0 answers