3
votes

I have a UINavigationController which I present modally. The modal is correctly presented in the orientation from which the phone is in. However when I dismiss the modal it immediately rotates to portrait and animates to the home button which is either to the left or right when in landscape mode. Navigation whilst the modal is open is all fine, rotating is fine, just not closing.

How can I simply get the modal to close in the orientation the device is in?

I have included an image of the modal being dismissed in landscape mode.

Before: View being dismissed

During: View during dismissal

As you can see the layout is quite broken. The current view presented in the NavigationController does not even resize to the portrait screen dimensions.

It may be worth mentioning that I am presenting a new sotryboard at this point aswell

    _storyboard = [UIStoryboard storyboardWithName:storyBoardName bundle:resourceBundle];
    _rootViewController = [_storyboard instantiateInitialViewController];
   [_sourceViewController presentViewController:_rootViewController animated:animated completion:nil];
1
Are you using first screen only in landscape?SNR
Check supported orientations of other View Controllers in storyboard.k06a
I don't think so, all screens have able to change to everything but upsidedown.Brenwell
I have put the following code in all viewcontrollers and uinavigationcontroller - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAllButUpsideDown; } Brenwell
Does it also seem strange that the underlying view controller is not visible in the second screenshot?Brenwell

1 Answers

1
votes

I believe I have solved my own problem. Updating UI from a background thread - Classic. What was happening is that I am firing the dismiss method from within a delegate method -(void)didLogin;. This delegate method was firing after a network call on a background thread. So when I tried to update the UI I was no longer on the main thread which was causing some very unusual UI behaviour.

[[NSOperationQueue mainQueue] addOperationWithBlock:^ {}];

This saved the day.