-1

iOS 6 で向きの方法が変更されました。ポートレート モードのアプリ全体が多くのビュー コントローラー (タブ バー ビュー コントローラーではありません) を取得しました。回転時に、ビュー コントローラーの 1 つをランドスケープ モード (実際には webView を表示) に回転させたいだけです。以下のメソッドは xcode 4.4 で機能していましたが、Xcode.4.5 では機能しません。

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

上記の方法は xcode 4.5 では機能しません。このため、以下の方法を変更しましたが、機能していません....何か提案があればよろしくお願いします。

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

1 に答える 1

1

タブバービューコントローラーを使用していますか? これを使用すると、1 つだけを回転させたい場合でも、すべてのタブのすべての View Controller を回転できるはずです。

-(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 に答える