Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have different orientations for viewControllers inside UINavigationController?

I want all view controllers to support only portrait mode, except one view controller lets call it "LandscapeSupportViewController" that should support also landscape mode.

The problem is when I'm in LandscapeSupportViewController in landscape mode and then push a new view controller that only support portrait mode, the pushed view controller will be in landscape mode also! How could I force it to be portrait?

I saw few apps that do it, take for example Skype iPhone app, the Messages tab is portrait only -> then if you press to enter the message itself you get a view controller that support landscape also because it make sense to enable landscape mode when user is chatting -> then if you press to view the persons profile, a new view controller will be pushed but in portrait! the same happen if you go back, you will forced to return to portrait even if you came from landscape...

Thanks

like image 555
Eyal Avatar asked Jan 18 '26 01:01

Eyal


2 Answers

I'd had students try to accomplish exactly what you are trying to accomplish, and after much research, the general consensus is: this is a bad idea and requires a lot of (App Store legal) hacks to accomplish, and still doesn't turn out too pretty (status bar, for example, screws up). You'll notice in the Skype app that when you go into the IM section, rotate to landscape, and hit back, the UI "snaps", or sort of gets instantly reloaded.

This is not a good user experience, and I'd recommend rethinking your design to be more in line with what Apple recommends.

like image 107
Christian Avatar answered Jan 20 '26 15:01

Christian


If i got you correctly you want to change device orientation in some conditions.

[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];

set your own orientation using above line, just put this lines inside the if condition. condition is depends on you.

Thank you!!

like image 41
TheTiger Avatar answered Jan 20 '26 14:01

TheTiger



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!