Thursday, June 19, 2014

Navigation controller and autorotation in iphone

The navigation controller before the view controller, destroying the code for disabling the autorotation  in the view controller class.

Assigning the class to navigation controller and there placed the code for disabling the autorotation worked.

- (BOOL)shouldAutorotate {
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;

}

--------- Full class for navigation controller
#import "UINavigationPortraitController.h"

@interface UINavigationPortraitController ()

@end

@implementation UINavigationPortraitController

- (BOOL)shouldAutorotate {
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end


and the header file

#import <UIKit/UIKit.h>

@interface UINavigationPortraitController : UINavigationController

@end

No comments:

Post a Comment