Xcode:如何构建仅横向模式的iPhone程序 [英] Xcode: how to build a landscape only iphone program

查看:49
本文介绍了Xcode:如何构建仅横向模式的iPhone程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆