Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone app in landscape mode, 2008 systems

Please note that this question is from 2008 and now is of only historic interest.


What's the best way to create an iPhone application that runs in landscape mode from the start, regardless of the position of the device?

Both programmatically and using the Interface Builder.

like image 979
Michiel de Mare Avatar asked Aug 02 '08 10:08

Michiel de Mare


People also ask

Why do some apps not work in landscape mode?

Ensure that you have enabled Auto-rotate for your tablet. To do this, swipe down on the tablet to display the status bar and touch Auto Rotate. Some mobile versions of apps do not support Landscape mode, so they may not be displayable in Landscape mode on the tablet.

Why do some apps only work in portrait on iPad?

Why so many apps are not built in both portrait and landscape mode? It's about time and cost of developing an app. If you force the app to work only in portrait, then it'll cost you less to build an app. For every screen there is a little bit of code and a bit more of visual design that comes with it.


2 Answers

Historic answer only. Spectacularly out of date.

Please note that this answer is now hugely out of date/

This answer is only a historical curiosity.


Exciting news! As discovered by Andrew below, this problem has been fixed by Apple in 4.0+.

It would appear it is NO longer necessary to force the size of the view on every view, and the specific serious problem of landscape "only working the first time" has been resolved.

As of April 2011, it is not possible to test or even build anything below 4.0, so the question is purely a historic curiosity. It's incredible how much trouble it caused developers for so long!


Here is the original discussion and solution. This is utterly irrelevant now, as these systems are not even operable.


It is EXTREMELY DIFFICULT to make this work fully -- there are at least three problems/bugs at play.

try this .. interface builder landscape design

Note in particular that where it says "and you need to use shouldAutorotateToInterfaceOrientation properly everywhere" it means everywhere, all your fullscreen views.

Hope it helps in this nightmare!

An important reminder of the ADDITIONAL well-known problem at hand here: if you are trying to swap between MORE THAN ONE view (all landscape), IT SIMPLY DOES NOT WORK. It is essential to remember this or you will waste days on the problem. It is literally NOT POSSIBLE. It is the biggest open, known, bug on the iOS platform. There is literally no way to make the hardware make the second view you load, be landscape. The annoying but simple workaround, and what you must do, is have a trivial master UIViewController that does nothing but sit there and let you swap between your views.

In other words, in iOS because of a major know bug:

[window addSubview:happyThing.view]; [window makeKeyAndVisible]; 

You can do that only once. Later, if you try to remove happyThing.view, and instead put in there newThing.view, IT DOES NOT WORK - AND THAT'S THAT. The machine will never rotate the view to landscape. There is no trick fix, even Apple cannot make it work. The workaround you must adopt is having an overall UIViewController that simply sits there and just holds your various views (happyThing, newThing, etc). Hope it helps!

like image 107
Fattie Avatar answered Sep 25 '22 01:09

Fattie


From the Apple Dev Site:

To start your application in landscape mode so that the status bar is in the appropriate position immediately, edit your Info.plist file to add the UIInterfaceOrientation key with the appropriate value (UIInterfaceOrientationLandscapeRight or UIInterfaceOrientationLandscapeLeft), as shown in Listing 2.

Listing 2: Starting your application in landscape mode

<key>UIInterfaceOrientation</key> <string>UIInterfaceOrientationLandscapeRight</string> 
like image 22
Michael Pryor Avatar answered Sep 26 '22 01:09

Michael Pryor