我在CDVLocation.m文件中使用phonegap 2.4创建新项目骨架时出错。我得到的错误是
if ([cdvViewController supportsOrientation:currentOrientation])
从枚举类型“UIDeviceOrientation”(又名“enum UIDeviceOrientation”)隐式转换为不同的枚举类型“UIInterfaceOrientation”(又名“enum UIInterfaceOrientation”)
因为我不知道OBJ-C,我不是100%肯定会发生什么事吗?
答案 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
}
}
}