繁体   English   中英

如何更改iDevice(iPad / iPhone)的方向?

[英]How to change the orientation of the iDevice (iPad/iPhone)?

通过以下操作很容易更改iPad / iPhone模拟器的方向:硬件->向左或向右旋转。 但是,如何在iDevice(iPad设备或iPhone设备)上进行更改?

请有人可以帮我吗?

我应该添加一些代码吗? 在此处输入图片说明

转到您的摘要选项卡,向下滚动以转到“ iPad部署信息”。 取消选择“支持的界面方向”中的所有四个选项。 然后再次选择,但先选择“肖像”,然后再选择“剩余”。

在此处输入图片说明

同样在您希望以纵向模式显示的视图中,只需添加

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
    return (orientation == UIInterfaceOrientationMaskAll);
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

希望这可以帮助。

转到支持文件中的.plist文件

在那里,您将看到支持的界面方向在按键下方添加

Item 0 String Portrait (top home button)
Item 1 String Portrait (bottom home button)
Item 2 String Landscape (left home button)
Item 3 String Landscape (right home button)

在此处输入图片说明

调用UIApplication的setStatusBarOrientation将伪造轮换

Initial interface orientation键/值添加到$appName-info.plist文件中

APP-的info.plist

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM