Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am developing an app for iOS 5, which have to run in landscape mode. My problem is that I cannot get it to flip initially.

I have tried the adding "Initial interface orientation" set to "Landscape (right home button)" and adding the following method to my view controller:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

I can wrap my head around how it is supposed to work. (I found the code here)

I am also wondering how to use the "Supported Device Orientation" available in the Xcode 4.2 project setup, it does not seem to do anything.

I have been looking around the website and have not been able to find an example that solves my problem.

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
606 views
Welcome To Ask or Share your Answers For Others

1 Answer

In your application’s Info.plist file, add the UIInterfaceOrientation key and set its value to the landscape mode. For landscape orientations, you can set the value of this key to UIInterfaceOrientationLandscapeLeft or UIInterfaceOrientationLandscapeRight.

Lay out your views in landscape mode and make sure that their autoresizing options are set correctly.

Override your view controller’s shouldAutorotateToInterfaceOrientation: method and return YES only for the desired landscape orientation and NO for portrait orientations.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...