The status bar and screen will be rotated with animation to the desired
orientation.
To use the AppDelegate must have the main view controller that extends
CDVViewController as a member variable called viewController.
This main view controller must also have the following modifications.
Header file should have the below allowed orientations variable
introduced.
@interface MainViewController : CDVViewController {
NSMutableArray *allowedOrientations;
}
@property (nonatomic, retain) NSMutableArray *allowedOrientations;
Source file should have the allowedOrientations synthesized.
@synthesize allowedOrientations;
Then perform setup in viewDidLoad method. UIDeviceOrientationPortrait
can be replaced with UIDeviceOrientationLandscapeRight depending on
desired start up orientation.
- (void) viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.allowedOrientations = [NSMutableArray array];
[self.allowedOrientations addObject:[NSNumber
numberWithInt:UIDeviceOrientationPortrait]];
}
Finally implement shouldAutorotateToInterfaceOrientation method with
the following.
- (BOOL)
shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
Orientation
{
// Return YES for supported orientations
return [allowedOrientations containsObject:[NSNumber
numberWithInt:interfaceOrientation]];
}