0

重複の可能性:
特定のView Controllerで画面の向きを強制する方法は?

こんにちは

ある特定のビューで向きを設定したいので、どうすればそれを行うことができますか。andbodyにはその例があります。私は使用しました

-(void)onUIDeviceOrientationDidChangeNotification:(NSNotification*)notification{
    UIViewController *tvc = self.navigationController.topViewController;
    UIDeviceOrientation orientation = [[ UIDevice currentDevice ] orientation ];
    tabBarController.view.hidden = YES;
    // only switch if we need to (seem to get multiple notifications on device)
    if( orientation != [[ UIApplication sharedApplication ] statusBarOrientation ] ){
        if( [ tvc shouldAutorotateToInterfaceOrientation: orientation ] ){
            [ self rotateInterfaceToOrientation: orientation ];
        }
    }
}

でもそれはアプリケーション全体で、1つの画面だけでやりたいので返信してくださいありがとうございます

4

3 に答える 3

0

このメソッドをクラスに追加します

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // Over ride this method in your required view controller to display only in the necessary orientation
     return YES;
}
于 2011-05-11T06:50:44.857 に答える
0

特定のビューコントローラに置く

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

これは他のuが賢明なようにできることのpotraitのためです

于 2011-05-11T06:55:51.367 に答える