0

ビューが表示されるときのデバイスの向きを知りたいです。以前はこのshouldAutorotateToInterfaceOrientationメソッドを使用して可能でしたが、IOS 6 では廃止されました。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    if (interfaceOrientation==UIInterfaceOrientationPortrait ||interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown ) {
        DashBtn.hidden=NO;
    }
    else
    {
        DashBtn.hidden=YES;
        if (self.popoverControllerMain) {
            [self.popoverControllerMain dismissPopoverAnimated:YES];
        }


    }
    return YES;
}

私はすべての投稿をチェックしました。つまり、rootviewcontrollerを作成し、

- (BOOL)shouldAutorotate {
    return NO;
}// this method is not called

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
4

3 に答える 3

1

使ってみて

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

それ以外の

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

詳細については、 http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.htmlを参照してください。

于 2012-10-30T07:33:07.437 に答える
1

UINavigationController のカテゴリを作成し、以下のコード @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]; }

@終わり

于 2012-10-30T09:14:34.050 に答える
0

デバイスの向きを知るための最良のオプションは

[[UIApplication sharedApplication] statusBarOrientation]
于 2012-10-30T07:35:14.653 に答える