Xcode 4 Supported Device Orientations
Asked Answered
C

2

6

I recently upgraded to Xcode 4. Previously in Xcode 3 to set the allowed device orientations you had to edit the shouldAutorotateToInterfaceOrientation: method in the application delegate. But now in Xcode 4 I see there is an option in Targets -> Summary where you can select different orientations.

Which alternative will rule over the other?

Cheers,

Peter

Carmen answered 17/5, 2011 at 12:17 Comment(0)
G
9

Your memory is slightly faulty; shouldAutorotateToInterfaceOrientation: is in custom subclasses of UIViewController. So it allows each view controller to say which orientations it works in individually. So you can have an app that overwhelmingly works in portrait or landscape, but has a view view controllers that only work in portrait, for example — which is useful if you're incorporating off-the-shelf code.

The supported device orientations in targets -> summary go into your Info.plist, to provide metadata to the OS without it having to launch your app.

Ideally the two should agree, and I don't think either one overrides the other. The summary information should summarise all of your various view controllers, but I'd be surprised if you got anything other than the odd weird launch behaviour if you fill it in incorrectly.

Greggrega answered 17/5, 2011 at 12:25 Comment(1)
The stuff in Info.plist affects how the app will appear when the OS launches it and displays the startup image. After that, the controllers' shouldAutorotateToInterfaceOrientation: methods control everything.Tavish
F
1

The "target summary" is just short hand for the data in the Info.plist file and so this has been available before. Nothing new here.

Fetter answered 17/5, 2011 at 12:22 Comment(1)
So continue to use shouldAutorotateToInterfaceOrientation:.Janycejanyte

© 2022 - 2024 — McMap. All rights reserved.