Xcode:如何构建仅横向模式的iPhone程序 [英] Xcode: how to build a landscape only iphone program
问题描述
在Xcode中,我尝试设计仅横向用户界面.
in Xcode, I tried to design a landscape only user interface.
我都将UIViewController和UIView控件设置为横向模型.但是,当我将控件(如按钮,图像)放在UIView上时,在程序运行时,只有放在左上角区域的控件才会响应.似乎程序仍在纵向模式下运行.
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.
推荐答案
在Landscape (left home button)
中的项目plist设置Initial interface orientation
字段中.还要设置Supported interface orientations
字段.
In project plist setup Initial interface orientation
field in Landscape (left home button)
. Also setup Supported interface orientations
field.
并在您的ViewController中覆盖方法-(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
:
And override method -(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
in your ViewController:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
这篇关于Xcode:如何构建仅横向模式的iPhone程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!