在 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;
}