Create Inherited class of NavigationController
BaseNavigationController.h
import
@interface BaseNavigationController : UINavigationController
@end
BaseNavigationController.m
pragma mark- Orientation changes handling
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
BOOL shouldAutorotateBool = NO;
if ([self isRotate])
{
if([[self.viewControllers lastObject] respondsToSelector:@selector(shouldAutorotate)])
shouldAutorotateBool = [[self.viewControllers lastObject] shouldAutorotate];
}
return shouldAutorotateBool;
}
// iOS6/7 support
- (NSUInteger) supportedInterfaceOrientations {
NSUInteger interfaceOrientation = UIInterfaceOrientationMaskPortrait;
if ([self isRotate]) {
if([[self.viewControllers lastObject] respondsToSelector:@selector(preferredInterfaceOrientationForPresentation)]) {
interfaceOrientation = [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
}
return interfaceOrientation;
}
-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation
{
UIInterfaceOrientation interfaceOrientation = UIInterfaceOrientationPortrait;
if ([self isRotate]) {
if([[self.viewControllers lastObject] respondsToSelector:@selector(preferredInterfaceOrientationForPresentation)]) {
interfaceOrientation = [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
}
return interfaceOrientation;
}
-(BOOL)shouldAutorotate
{
BOOL shouldAutorotateBool = NO;
if ([self isRotate])
{
if([[self.viewControllers lastObject] respondsToSelector:@selector(shouldAutorotate)])
shouldAutorotateBool = [[self.viewControllers lastObject] shouldAutorotate];
}
return shouldAutorotateBool;
}
-(BOOL) isRotate
{
if ([[self.viewControllers lastObject] isMemberOfClass:NSClassFromString(@"VideoVC")]) {
return YES;
}
return NO;
}
**And the particular viewController use the following Code for orientation**
pragma mark- Methods for device orientation handling
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeLeft;
}
-(BOOL)shouldAutorotate
{
return YES;
}