-1

I am receiving 2 errors while a dismissal is happening in my app.
Warning: Attempt to dismiss from view controller <MyNavigationController> while a presentation or dismiss is in progress!
&
Unbalanced calls to begin/end appearance transitions for <MainViewController>.

I've searched around and everywhere says that there is usually a conflicting dismissal happening where a button is calling the transition both programmatically and through the storyboard. I, however, am receiving these errors when using the normal back button that comes with nav controllers. I don't do anything with the button at all.

The only thing I can link to the errors is that my nav controller is autorotating while trying to dismiss the view controller. If I remove autorotate or set the orientation of both view controllers to be the same then I don't get the error. Problem is, I need one of the view controllers to be portrait and the other to be landscape...

This is how I set the orientation

NavController.m:

- (NSUInteger)supportedInterfaceOrientations { return self.topViewController.supportedInterfaceOrientations; } - (BOOL)shouldAutorotate { return YES; } 

MainViewController.m:

- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 

OtherViewController.m:

- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight; } 

I've noticed that for some reason it doesn't autorotate when going to my "OtherViewController", but it apparently tries to autorotate while returning to the "MainViewController", thus causing the crash.

Since it may be relevant, this is how I load my OtherViewController:

[self performSegueWithIdentifier:titles[indexPath.row] sender:nil]; 

I have a CollectionViewController that calls a push segue I have set up in the storyboard. Titles is an NSArray of the different segue titles connected to the MainViewController.

Here is the flow of what's going on in my app:

MainViewController : LoadView MainViewController : ViewWillAppear MainViewController : ViewDidAppear //This is where I choose to load the OtherViewController OtherViewController : LoadView MainViewController : ViewWillDisappear OtherViewController : ViewWillAppear MainViewController : ViewDidDisappear OtherViewController : ViewDidAppear //This is where I select the "Back" button Warning: Attempt to dismiss from view controller NavController while a presentation or dismiss is in progress! Unbalanced calls to begin/end appearance transitions for MainViewController. MainViewController : ViewWillDisappear MainViewController : ViewDidDisappear 
2
  • Add this to your code: NSLog(@"%@",[self.navigationController viewControllers]); and tell me what it prints out. Commented Jun 21, 2014 at 16:22
  • (MyMainViewController, OtherViewController) Both View controllers that should be there are there Commented Jun 22, 2014 at 17:09

2 Answers 2

0

For a detailed analysis we need more code, especially where the view controller is dismissed.

As for your error message the dismissal call, whichever you use, is called in the middle of some other workflow of showing or dismissing a view controller. That could be when you present or dismiss a modal view controller or when you push or pop one on the navigation stack in

  • loadView
  • viewDidLoad
  • viewWillAppear
  • viewDidAppear
  • viewWillDisappear
  • viewDidDisappear

This list is certainly incomplete but that should be the most common methods that are called within the process.

So share some more code with us.

Sign up to request clarification or add additional context in comments.

3 Comments

I threw comments into everything you suggested and it appears that my log output in ViewDidDisappear never gets logged. So my OtherViewController isn't even being told to disappear... ViewWillAppear and LoadView are not called on my MainViewController either
I did notice something strange. After receiving the two errors, the MainViewControllers calls both ViewWillDisappear and ViewDidDisappear..
There is nothing strange with ...With... and ...Did... beeing called. It is rahter a matter of sequence and you can make use of that.
0

Without getting into too much details, you need to find a way to do one after the other. The tricky part is that there is no delegate that tells you when a view was dismissed after a segue. However, after a segue, when viewWillAppear is called, the previous view was dismissed. Maybe try to rotate the view from the code, and do so in the viewWillAppear?

1 Comment

The only way I've been able to force rotation is via this answer tweaked a bit to work like what this person did, but all this did was make autorotate work when going to my OtherViewController. It still has the same crash when returning to my MainViewController

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.