I am having custom split view controller in my App with a master controller and a detailed controller.
- (id)initWithMasterController:(UIViewController*)aMasterController
detailedController:(UIViewController*)aDetailedController;
The controllers provided for the master controller and details controller are UINavigationController.
As part of my app, there are two possible cases for orientation handling:
- When six combination of controllers are used in master and details controller, all the orientations are supported for the app.
- When there is a StudentDetailsViewController at the details controller alone, only two possible orientations can be supported. (Landscape)
When ever the device's orientation is changed, the below things happen in versions below iOS 6.0
The
-shouldAutorotateToInterfaceOrientation:
method gets called. The implementation of that method is below: At run time, I forward the request to master controller and details controller with the same call.- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { BOOL res = [masterController shouldAutorotateToInterfaceOrientation:interfaceOrientation] && [detailedController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; return res; }
The masterController's
-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 get information on the new orientation to be changed helps me to decide if rotation should be enabled or not.
With iOS 6.0:
When ever the device's orientation is changed, the below things happen in versions of iOS 6.0
The method
-shouldAutorotate
of the split view controller gets called. Its implementation is below- (BOOL)shouldAutorotate { BOOL res = [masterController shouldAutorotate] && [detailedController shouldAutorotate]; return res; }
The detailedController's shouldAutorotate calls the navigationController. The implementation of autorotate feature in StudentsController:
- (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight); }
But with iOS 6.0, I am unable to control the orientation. Even though the supportedInterfaceOrientations method gets called, when the shouldAutorotate method of the StudentsDetailsController gets called, from the detailsController's shouldAutorotatemethod, the shouldAutorotateMethod does not obey the options mentioned in the supportedInterfaceOrientations method.
UPDATE:
I read the docs and the below notes are provided in the document.
sometimes you may want to dynamically disable automatic rotation. For example, you might do this when you want to suppress rotation completely for a short period of time. You must temporarily disable orientation changes you want to manually control the position of the status bar (such as when you call the setStatusBarOrientation:animated: method).
If you want to temporarily disable automatic rotation, avoid manipulating the orientation masks to do this. Instead, override the shouldAutorotate method on the topmost view controller. This method is called before performing any autorotation. If it returns NO, then the rotation is suppressed.
Is it possible to temporarily disable automatic rotation based on the current orientation?