Phonegap 2.4.0价值转换问题

时间:2013-03-28 13:02:04

标签: ios objective-c cordova

我在CDVLocation.m文件中使用phonegap 2.4创建新项目骨架时出错。我得到的错误是 if ([cdvViewController supportsOrientation:currentOrientation]) 从枚举类型“UIDeviceOrientation”(又名“enum UIDeviceOrientation”)隐式转换为不同的枚举类型“UIInterfaceOrientation”(又名“enum UIInterfaceOrientation”)

因为我不知道OBJ-C,我不是100%肯定会发生什么事吗?

1 个答案:

答案 0 :(得分:1)

currentOrientation的类型为UIDeviceOrientation,其值大于UIInterfaceOrientation

由于该方法需要UIInterfaceOrientation而不是UIDeviceOrientation

<强>替换

  • <击> supportsOrientation:currentOrientation
  • supportsOrientation:[[UIApplication sharedApplication] statusBarOrientation]]

尝试更改CDVLocation.m中的方法:

if ([self.locationManager respondsToSelector:@selector(headingOrientation)]) {
    UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];
    if (currentOrientation != UIDeviceOrientationUnknown) {
        CDVViewController* cdvViewController = (CDVViewController*)self.viewController;

        //change this line
        if ([cdvViewController supportsOrientation:[[UIApplication sharedApplication] statusBarOrientation]]) {
            self.locationManager.headingOrientation = (CLDeviceOrientation)currentOrientation;
            // FYI UIDeviceOrientation and CLDeviceOrientation enums are currently the same
        }
    }
}