IOS 6 Question about rotation - no rotation from the presented Modal View controller

I have a MainViewController that has a button that pushes a new view (InfoViewController) through flip horizontailly. So:

controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; 

The MainView controller supports Portrait and PortraitUpsideDown. For example:

 - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); } 

My InfoViewController also shows the above code. In my AppDelegate, it has this in LaunchOptions:

 [self.window setRootViewController:self.mainViewController]; 

In my app.plist file it supports all orientations. This is because other views must also support the landscape. So on my MainViewController and InfoViewController, I only need Portrait and PortraitUpsideDown. But, in another opinion, I need all orintations.

My MainViewController works fine, but my InfoViewController works for all orientations.

I am extreme trying to get this to work in iOS6. I researched other posts and tried to help other people, but no luck. Please can someone help me get this thanks. And I'm new to Objective-C: p

+16
ios objective-c ios6
Sep 23 '12 at 16:50
source share
4 answers

Do not support all orientations in the application plist file, only those supported by your root controller.

Authorization changes in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: UIViewController method is deprecated. Instead, you should use the supportedInterfaceOrientationsForWindow: and shouldAutorotate :

 - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAllButUpsideDown; } 

Modal ViewControllers no longer receive rotation calls in iOS 6: willRotateToInterfaceOrientation:duration:, willAnimateRotationToInterfaceOrientation:duration:, and didRotateFromInterfaceOrientation: methods are no longer called in any view controller, which makes a full-screen presentation (for example, those using: presentViewController:animated:completion:

You can let the view controller, which your modal view controller represents, inform it of rotation. Also, now you use: presentViewController:animated:completion: to represent the view controller. presentModalViewController:animated: deprecated that you are using in your code.

+26
Sep 23
source share

I solved similar problems using the tab bar controller.

Subclass of UITabBarController. Follow these methods:

 - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } - (BOOL)shouldAutorotate { NSLog(@"Orientation:%d", [[UIDevice currentDevice] orientation]); for (UIViewController *viewController in self.viewControllers) { [viewController shouldAutorotate]; } return YES; } 

If you want to handle rotations in the controllers inside the tabbarcontroller, each of the controllers in the table control panel also implements these methods and writes code to change the orientation. If you do not want to process it, you do not need to implement these methods. TabBarControllers methods will always execute when the orientation changes. Even twice for an unknown reason.

Yes, and don't forget to remove all toAutorotate methods. I completely switched to a new orientation model. If you want them to stay, it might be harder.

+3
Oct 08
source share

Create a category by subclassing the UINavigationController and execute the following methods in the .h file

 -(BOOL)shouldAutorotate; -(NSUInteger)supportedInterfaceOrientations; - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation; in .m file -(BOOL)shouldAutorotate { return [self.topViewController shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [self.topViewController supportedInterfaceOrientations]; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [self.topViewController preferredInterfaceOrientationForPresentation]; } 

and implement the following methods in the view controller class, class u wants to enable rotation

 -(NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown); } - (BOOL)shouldAutorotate { return YES; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; } 
0
Mar 25 '14 at 5:51
source share

add this code to a subclass of UITabBarController.m

 @implementation UINavigationController (rotation) //temp hack for iOS6, this allows passing supportedInterfaceOrientations to child viewcontrollers. - (NSUInteger)supportedInterfaceOrientations { return [self.topViewController supportedInterfaceOrientations]; } @end @implementation NameClassUITabBar - (void)viewDidLoad { [super viewDidLoad]; } - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } @end 

Here I posted my / experince solution in a panel controller with twists: http://luterr.blogspot.sg/2015/04/example-code-uiinterfaceorientationmask.html

0
Apr 16 '15 at 1:57
source share



All Articles