I am using MMDrawerController in my application from this link
I set the root ViewController in the AppDelegate this way:
self.leftDrawerController = [[LeftDrawerViewController alloc] init];
self.homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.homeViewController];
// DrawerViewController setup
self.drawerController = [[MMDrawerController alloc]
initWithCenterViewController:self.navigationController
leftDrawerViewController:self.leftDrawerController];
[self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
[self.drawerController setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
MMDrawerControllerDrawerVisualStateBlock block; block = [[DrawerVisualStateManager sharedManager] drawerVisualStateBlockForDrawerSide:drawerSide];
if (block) {
block(drawerController, drawerSide, percentVisible);
}
}];
[self.window setRootViewController:self.drawerController];
I want to disable rotation in a specific ViewController, I am calling those methods and they are never called and the view still rotate:
// ViewController.m
-(BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
I guess the problem is coming from the rootViewController which is the MMDrawerViewController!
I already checked this and this and this but nothing helped.
in MMDrawerController
override following methods something like.
-(BOOL)shouldAutorotate {
return [self.centerViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
return [self.centerViewController supportedInterfaceOrientations];
}
Try this if not successful then you need to subclass UINavigationController and override these methods then your viewcontrollers orientation settings would be passed in hierarchy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With