iPhone app in landscape mode, 2008 systems *

Question

Note: 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.

Answer

Historic answer only. Utterly out of date "2x".

Please note that the original answer here, became completely out of date after some years.

Just below the next dotted line, there's an out-of-date notice pointing out that the answer (ancient at the time) was totally out of date, and there is a test project and so on.

For today 2014, the whole thing is staggeringly out of date, none of these systems even exist any more. These sort of answers are left here for historic reasons. Cheers.


Exciting news! As discovered by Andrew below,

This problem has been fixed by Apple in 4.0+.

Here is a FULL TEST PROJECT you can download, that shows it working correctly in a "Landscape only" iPad app.

LandscapeOnlyProblemTest

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

As you can see in the demo project, you can swap out, leave only the raw app window, and insert another landscape view with no problem.

As of April 2011, there is no reason to support anything below 4.0, so the question is now only a historic curiosity. It's incredible how much trouble that caused so many developers for so long!


Purely for historical reasons...

here is the original discussion and solution (to repeat, this is totally irrelevant now) -->

It is EXTREMELY DIFFICULT to make this work fully properly -- 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!

< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/402/" >iPhone app in landscape mode, 2008 systems< /a>
Share on Google Plus

About Cinema Guy

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment