2017-06-04 18 views
0

親ビューコントローラがあります。 私は子供のviewcontrollerを持っています。 子ビューコントローラが終了すると、親ビューコントローラは横長状態のままです。してくださいアドバイス:=) これらの設定は、次のとおりです。 deployment info親ビューコントローラの回転を回避する方法

マイアプリデリゲート

-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
    UIViewController* topVC = [self getTopController]; 
    if ([topVC isKindOfClass: [childVideoViewController class]]) { 
     return UIInterfaceOrientationMaskLandscape; 
    } 
    return UIInterfaceOrientationMaskPortrait; 
} 

-(UIViewController*) getTopController{ UIViewController *topViewController =  [UIApplication sharedApplication].keyWindow.rootViewController; 

    while (topViewController.presentedViewController) { 
     topViewController = topViewController.presentedViewController; 
    } 
    return topViewController; 
} 

答えて

1

あなたが戻って子ビューコントローラから、あなたの子ビューコントローラのメソッドを作成し、この

を実装 を呼び出す必要があります子ビューから
- (void)setScreenOrientation:(UIInterfaceOrientation)orientation 
{ 
UIDeviceOrientation deviceOrientation = (UIDeviceOrientation) orientation; 
[[UIDevice currentDevice] setValue: [NSNumber numberWithInteger: deviceOrientation] forKey:@"orientation"]; 
} 

コールこれは以前に却下:

[self setScreenOrientation:UIInterfaceOrientationPortrait]; 

    [self dismissViewControllerAnimated:YES completion:nil]; 
+0

私のchildviewcontrollerがdelegate.setscreenorientation(肖像画)を呼び出した後、私の親viewcontrollerはまだランドスケープにあります。あなたの努力のために@ MasumBiswas-私の親viewcontrollerはまだ横たわっています。私は何が欠けていますか? – TheSnakeWizard

+0

それは私のために働いています。関数を呼び出さずに直接行ってください。 –

+0

子ビューコントローラを回転するために、アプリケーションデリゲート内に実装する必要はありません。あなたはviewdidloadのように以下のようにすることができます:[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@ "orientation"]; –

関連する問題