【发布时间】:2015-12-06 13:58:47
【问题描述】:
我想在 iPhone 中以两个方向显示一个视图控制器。当屏幕打开时,首选方向应该是纵向的。然后根据设备方向旋转。我找到了一些解决方案,屏幕也在旋转。但是当我进入屏幕时,它会自动旋转为横向,而我必须手动将其旋转为纵向。
这个问题有简单的解决办法吗?
【问题讨论】:
标签: ios objective-c iphone xcode orientation
我想在 iPhone 中以两个方向显示一个视图控制器。当屏幕打开时,首选方向应该是纵向的。然后根据设备方向旋转。我找到了一些解决方案,屏幕也在旋转。但是当我进入屏幕时,它会自动旋转为横向,而我必须手动将其旋转为纵向。
这个问题有简单的解决办法吗?
【问题讨论】:
标签: ios objective-c iphone xcode orientation
您应该实现 preferredInterfaceOrientationForPresentation 和 支持的接口方向如:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIDeviceOrientationPortrait;
}
//You don't actually need to implement this as UIInterfaceOrientationMaskAllButUpsideDown is the default for iPhone
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
【讨论】: