开发者

how do you make an app ONLY support landscape?

开发者 https://www.devze.com 2023-03-01 11:52 出处:网络
how do you mak开发者_Python百科e an app ONLY support landscape? No portrait mode JUSTlandscape throughout the whole thing in xcode 3?The accepted answer did not work for me. This did:

how do you mak开发者_Python百科e an app ONLY support landscape? No portrait mode JUST landscape throughout the whole thing in xcode 3?


The accepted answer did not work for me. This did:

In the properties file for your app (YOURAPPNAME-Info.plist), located in the "supporting files" group, there is an array called "Supported interface orientations". Remove the orientations you don't want from the array, and your app will be locked into the remaining orientation.


My naive answer is to add this method in all of your root view controllers:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight)
        return YES;

    return NO;
}

This is what I do in my game. Of course, my game only has one view controller.

Also, I found it helpful to set "Initial interface orientation" in my app's info.plist to Landscape.


You can change the Supported interface orientations in your info.plist file, as shown below:

how do you make an app ONLY support landscape?


Orientations are now easily set using the target's summary tab.


We can change the orientation by simply selecting the required orientations as well. Select the device from "devices" and change the orientation

how do you make an app ONLY support landscape?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号