我有父视图控制器 - 纵向。 我有儿童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;
}
答案 0 :(得分: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];