When running the app on iOS 6, my app no longer successfully autorotates. I have updated to Cordova 2.1, and I have the following code in my MainViewController.m
file (which is a subclass of CDViewController
, to be compatible with the new iOS6 way of handling autorotation:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
// iOS 6
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger ret = 0;
if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait])
ret = ret | (1 << UIInterfaceOrientationPortrait);
if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown])
ret = ret | (1 << UIInterfaceOrientationPortraitUpsideDown);
if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight])
ret = ret | (1 << UIInterfaceOrientationLandscapeRight);
if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft])
ret = ret | (1 << UIInterfaceOrientationLandscapeLeft);
return ret;
}
In your AppDelegate.m you need to add the following to didFinishLaunchingWithOptions
[self.window setRootViewController:self.viewController];
Once you add this, rotation should start working again. It has for my two apps.