I have a split view user controller in my application with a main controller and a detailed controller.
- (id)initWithMasterController:(UIViewController*)aMasterController detailedController:(UIViewController*)aDetailedController;
The controllers provided for the master controller and data controller are the UINavigationController.
As part of my application, there are two options for handling orientation:
- When six combinations of controllers are used in the master and details controller, all applications are supported for the application.
- When there is only StudentDetailsViewController in the data controller, only two possible orientations can be supported. (Horizontally)
When the orientation of the device changes, below everything happens in versions below iOS 6.0
The -shouldAutorotateToInterfaceOrientation: method is -shouldAutorotateToInterfaceOrientation: . The implementation of this method is given below: at runtime, I forward a request to control the controller and the data controller with the same call.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { BOOL res = [masterController shouldAutorotateToInterfaceOrientation:interfaceOrientation] && [detailedController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; return res; }
The Controller wizard -shouldAutorotateToInterfaceOrientation will return TRUE. The implementation of the method in StudentViewController is below.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (IS_IPAD) ? UIInterfaceOrientationIsLandscape(interfaceOrientation) : UIInterfaceOrientationIsPortrait(interfaceOrientation); }
The ability to receive information about a new orientation that needs to be changed helps me decide whether to enable rotation or not.
With iOS 6.0:
When the orientation of the device changes, the following happens in versions of iOS 6.0:
The -shouldAutorotate method of the -shouldAutorotate controller is called. Its implementation is below.
- (BOOL)shouldAutorotate { BOOL res = [masterController shouldAutorotate] && [detailedController shouldAutorotate]; return res; }
The detailed controller shouldAutorotate calls the navigationController. Implementation of the autorotation function in StudentsController:
- (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight); }
But with iOS 6.0, I canβt control the orientation. Although the supportedInterfaceOrientations method is called when the shouldAutorotate method is called for the StudentsDetailsController method, from the detailsController method shouldAutorotatemethod, the shouldAutorotateMethod method does not obey the parameters specified in the supportedInterfaceOrientations method.
UPDATE:
I have read the docs and the notes below are presented in the doc.
sometimes you may need to dynamically disable auto-rotation. For example, you can do this when you want to suppress the rotation completely for a short period of time. You must temporarily disable orientation changes that you want to manually control the position (for example, when you call the setStatusBarOrientation: animated: method).
If you want to temporarily disable auto-rotation, avoid manipulating orientation masks for this. Instead, override shouldAutorotate on the top controller. This method before performing any autorotation. If it returns NO, then the rotation is suppressed.
Is it possible to temporarily disable auto-rotation based on the current orientation?