我在 UITabBarController 中有一个 UINavigationController。我尝试了社区关于 iOS 6 中自动旋转的所有建议,但没有成功,最后我决定为 UINavigationController 创建一个类别,该类别没有对 orientaion 进行任何更改(尽管确实调用了这些函数)
然后我为 UITabBarController 创建了一个类别,如下所示:
#import "UITabBarController+ios6Rotate.h"
@implementation UITabBarController (ios6Rotate)
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortraitUpsideDown;;
}
@end
得到了这个:
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!
但是我所有的方向都支持?!唔
然后我将代码更改为:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortraitUpsideDown;
}
这使我的应用程序颠倒了,但仍然不会旋转。我不明白发生了什么事。在这一点上,我想在 ios6 中看到任何形式的旋转,我不在乎哪一边,但似乎没有任何效果。