【发布时间】:2012-12-17 18:37:53
【问题描述】:
我正在开发 iOS 6 应用程序,我使用以下方法处理了 UIview 旋转...
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL) shouldAutorotate {
return YES;
}
一切正常,问题是初始视图加载是根据设备方向决定的,例如:如果我将设备保持在横向模式,即使我在supportedInterfaceOrientations 视图中强制返回纵向,一旦设备显示为横向之后旋转为纵向,它不会进入横向模式,一切正常。无论设备方向如何,是否可以在特定模式下加载视图?
我用谷歌搜索过,没有任何效果。
注意:我正在使用导航控制器。我还为 UINavigationController 添加了类别。
// IOS6 中用于处理方向的自定义类别
@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
谢谢
【问题讨论】:
标签: objective-c ios xcode cocoa-touch uiview