Xcode:如何构建仅风景的 iphone 程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5777313/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:54:18  来源:igfitidea点击:

Xcode: how to build a landscape only iphone program

iphonexcode

提问by Xcobe

in Xcode, I tried to design a landscape only user interface.

在 Xcode 中,我尝试设计一个仅限横向的用户界面。

I both set UIViewController and UIView controls to landscape model. but when I placed the controls, like buttons, images on the UIView, when programe running, only the controls which are placed on top-left area response. Seems the programe is still running in portrait mode.

我都将 UIViewController 和 UIView 控件设置为横向模型。但是当我在 UIView 上放置控件(如按钮、图像)时,当程序运行时,只有放置在左上角区域的控件才会响应。似乎该程序仍在纵向模式下运行。

回答by Alex Nazarsky

In project plist setup Initial interface orientationfield in Landscape (left home button). Also setup Supported interface orientationsfield.

在项目的plist设置Initial interface orientation字段Landscape (left home button)。还有设置Supported interface orientations字段。

And override method -(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientationin your ViewController:

-(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation在您的 ViewController 中覆盖方法:

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