Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force a screen orientation in specific view controllers?

My application is pretty simple: it starts up with a view controller that holds a table view (in grouped view layout) with a few options. When the user taps on one of the options, I push another view controller onto my navigation controller.

This second view controller simply displays a UIImageView, and the user can change the screen orientation on this view controller between portrait/landscape modes. This works just fine, and all is happy.

However, if the user taps on the "Back" button on my navigation bar while on the landscape mode, the first controller's layout is all messed up. See below for before/after screenshots:

before
(source: pessoal.org)
after
(source: pessoal.org)

Any clues on how to force the first view controller (second screenshot in this post) to stay within the portrait screen orientation?

like image 641
jpm Avatar asked Nov 24 '08 14:11

jpm


People also ask

How do I control screen orientation?

Android Settings Start by going to Settings => Display and locate the “Device rotation” setting. On my personal cell phone, tapping this will reveal two options: “Rotate the contents of the screen,” and “Stay in portrait view.”

How do I change orientation mode?

Select the Start button, then type settings. Select Settings > System > Display, and choose a screen orientation from the drop-down list next to Display orientation.


1 Answers

There does not appear to be a way to do this using the documented methods.

I have filed a bug for this: rdar://6399924

"There is no way to always restrict a UIViewController to one orientation"

You can see it on open radar (along with a link to sample code to reproduce the problem) here: http://openradar.appspot.com/radar?id=697

like image 187
lfalin Avatar answered Sep 27 '22 16:09

lfalin