0

我的大部分应用程序不支持轮换。在支持的方向上,我只选择了肖像。在应用程序使用的 UIViewController 子类上,我有这个:

-(BOOL)shouldAutorotate {
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations {
    NSLog(@"supported?");
    return UIInterfaceOrientationMaskPortrait;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

    NSLog(@"preferred");
    return UIInterfaceOrientationPortrait;
}

在支持方向的 UIViewController 子类中,我有这个:

-(BOOL)shouldAutorotate {
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations {
    NSLog(@"supported?");
    return UIInterfaceOrientationMaskAll;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

    NSLog(@"preferred");
    return UIInterfaceOrientationPortrait;
}

但是,我的应用程序不会在任何视图上旋转,包括这个。如何让它按照我的意愿在这里旋转?

4

1 回答 1

1

如果您使用的是导航控制器,请确保在您的 App Delegate 中执行此操作:

self.window.rootViewController = self.navigationController;

有关其他参考资料,请从 SO 检查此问题:

旋转在 iOS6 上表现不同

于 2012-10-03T17:59:34.220 回答