jun*_*ege 4 rotation auto-rotation cordova ios6
在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;
}
Run Code Online (Sandbox Code Playgroud)
小智 8
在AppDelegate.m中,您需要将以下内容添加到didFinishLaunchingWithOptions中
[self.window setRootViewController:self.viewController];
Run Code Online (Sandbox Code Playgroud)
添加后,旋转应该再次开始工作.它有我的两个应用程序.
| 归档时间: |
|
| 查看次数: |
2715 次 |
| 最近记录: |