-1

the orientation methods have changed in iOS 6. my whole app in portrait mode got to many view controllers (not tab bar view controllers) i just want to rotate one of my view controller to landscape mode (it actually displays a webView) when i rotate the device.the below method was working in xcode 4.4 but, it's not in Xcode.4.5

- (BOOL)shouldAutorotateToInterfaceOrientation:
  (UIInterfaceOrientation)interfaceOrientation {
  return (interfaceOrientation == UIInterfaceOrientationPortrait ||
 interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
interfaceOrientation == UIInterfaceOrientationLandscapeRight );

the above method won't work in xcode 4.5 for this reason i have changed the below method but even though its not working....plz any suggestions thanks.

 - (BOOL) shouldAutorotate{
 [[UIApplication sharedApplication] setStatusBarOrientation:           UIInterfaceOrientationPortrait];
  return self.modalViewController.shouldAutorotate;
}
 -(NSUInteger)supportedInterfaceOrientations
{
  return UIInterfaceOrientationMaskLandscape;
}
4

1 回答 1

1

你使用标签栏视图控制器吗?如果你使用它,那么所有选项卡中的所有视图控制器都应该能够旋转,即使你只想旋转一个。

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

这在 iOS6 中应该可以正常工作。


如果你使用 UINavigationViewController,那么它的方法就会被调用。还有另一种解决方案。

// App delegate.m
- (NSUInteger)application:(UIApplication *)application    supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    NSUInteger orientations = UIInterfaceOrientationMaskAllButUpsideDown;

    if(self.window.rootViewController){
        UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
        orientations = [presentedViewController supportedInterfaceOrientations];
    }

    return orientations;
}

然后在视图控制器中

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}
于 2013-02-01T22:32:50.803 回答