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;
}
否 - 它不工作 - 感谢您的努力@ MasumBiswas - 我的父视图控制器仍然在横向后,我的childviewcontroller调用应用程序delegate.setscreenorientation(肖像)。我错过了什么? – TheSnakeWizard
它为我工作。请不要直接调用函数 –
不需要在应用程序委托中实现来旋转你的子视图控制器。你可以在viewdidload中这样做:[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@“orientation”]; –