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