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