Modal UINavigationController - I Can't Stop Rotating

I use storyboards and I have a UINavigationController built into the UITabBarController. I click on the view controller, and then from this view controller, I present the MODAL UINavigationController with the UIViewController.

The problem is that the modal view controller can rotate when all my representations preceding the modal view cannot. How to stop the Modal nav controller, allowing any rotation?

I tried to add:

-(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 

and

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } 

thanks

+4
source share
1 answer

try the UINavigationController categories

 @implementation UINavigationController (Rotation_IOS6) -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation]; } 
+5
source

Source: https://habr.com/ru/post/1445363/


All Articles