【发布时间】:2012-12-07 01:59:19
【问题描述】:
我的 iOS 应用程序似乎有问题。
它的部署目标是iOS5.0,但是我使用的是iOS 6.0 SDK。
在我的视图控制器中,我有:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
这在 iOS5 模拟器中运行时可以正常工作。 视图不会旋转到 LandScape 或倒置。
但是,在 IOS6 模拟器中(以及在设备上),它将继续旋转。
我使用NSLog 来检查-supportedInterfaceOrientations 是否被调用并且确实调用了两次,但是它仍然旋转到LandScape(右或左)
我做错了什么?
我还扩展了UINavigationController(我的根视图控制器)以包含以下内容:
@implementation UINavigationController (Rotation_IOS6)
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
@end
但还是没有成功。
编辑
根据马特的回答。我还需要使用与我的 UINavigationController 类似的实现来扩展 UITabBarController 并且这很有效。
【问题讨论】:
标签: ios ios6 screen-orientation