在 Xcode 中,我尝试设计一个仅横向的用户界面。
我将 UIViewController 和 UIView 控件都设置为横向模型。但是当我将控件(如按钮、图像)放置在 UIView 上时,当程序运行时,只有放置在左上角区域的控件会响应。看来程序仍在纵向模式下运行。
最佳答案
在项目plist设置中横向(左侧主页按钮)
中的初始界面方向
字段。还设置支持的界面方向
字段。
并在 ViewController 中重写方法 -(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
关于iphone - Xcode:如何构建仅横向的 iPhone 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5777313/