Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modal in landscape orientation swaps to portrait when dismissed

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];
like image 370
Brenwell Avatar asked Feb 03 '26 20:02

Brenwell


1 Answers

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.

like image 110
Brenwell Avatar answered Feb 05 '26 12:02

Brenwell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!