Portrait mode only-iOS

2019-02-18 16:38发布

I have an application and designed for only for portrait orientation. However I dont know how to restrict to use only portrait mode, once user upside down or landspace mode, I dont want my screen orinetation changes accordingly.

Any ideas how to do it?

2条回答
狗以群分
2楼-- · 2019-02-18 17:10

That can be specified in the App Summary (and also in the rootviewcontroller (whether that be a Nav Controller, TabBar Controller, etc) by overriding this method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

enter image description here

查看更多
对你真心纯属浪费
3楼-- · 2019-02-18 17:23

Here's an updated view of the place where you can make the change in XCode 8.1

Set App Orientation Notice that you choose that item (App Summary) on the far left at the top of the project navigator. Then, on the right side you need to make sure that General is chosen at the top, then scroll down if needed and you'll see the Device Orientation settings.

xcode 8.1

查看更多
登录 后发表回答