在iOS 6上运行应用程序时,我的应用程序不再成功自动旋转。我已经更新到Cordova 2.1,并在我的MainViewController.m
文件中添加了以下代码(它是CDViewController
子类,以与新的iOS6处理自动旋转方式兼容):
- (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;
}