Post

Replies

Boosts

Views

Activity

Reply to Device orientation on only 1 view controller? in objective c
in your AppDelegate -(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ @try { UIViewController *rootViewController = window.rootViewController; // Check if the root view controller is a navigation controller if ([rootViewController isKindOfClass:[UINavigationController class]]) { UINavigationController *navigationController = (UINavigationController *)rootViewController; // Check if the top view controller of the navigation controller is valid if (navigationController.topViewController != nil) { UIViewController *topViewController = navigationController.topViewController; // Check if the top view controller is an instance of the viewcontroller you want it to be landscape if ([topViewController isKindOfClass:[MRFullScreenVC class]]||[topViewController isKindOfClass:[MRPlaybackFullScreenVC class]]) { YXHLog(@"supportedInterfaceOrientationsForWindow is Landscape"); return UIInterfaceOrientationMaskLandscape; } } } YXHLog(@"supportedInterfaceOrientationsForWindow is Portrait"); return UIInterfaceOrientationMaskPortrait; } @catch (NSException *exception) { YXHLog(@"Exception caught: %@", exception); // Handle the exception gracefully, for example, by logging the error and returning a default value return UIInterfaceOrientationMaskPortrait; } }
Mar ’24