0

I'm getting an error when I create a new project skeleton using phonegap 2.4 in my CDVLocation.m file. The error I'm getting is
if ([cdvViewController supportsOrientation:currentOrientation])
Implicit conversion from enumeration type "UIDeviceOrientation"(aka "enum UIDeviceOrientation") to different enumeration type "UIInterfaceOrientation" (aka "enum UIInterfaceOrientation")

Im not 100% sure whats going on here since I dont know OBJ-C, any idea?

mhartington
  • 6,905
  • 4
  • 40
  • 75
  • can you see the implementation of `supportsOrientation:` i think its a custom method – jermel Mar 28 '13 at 13:06
  • I think, like I said I dont know OBJ-C so I'm guess this is it.
    `- (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation { return [self.supportedOrientations containsObject:[NSNumber numberWithInt:orientation]]; }`
    – mhartington Mar 28 '13 at 13:11
  • Maybe this helps http://stackoverflow.com/questions/7015709/xcode-getting-warning-implicit-conversion-from-enumeration-type-uideviceorient – jermel Mar 28 '13 at 13:43

1 Answers1

1

currentOrientation is of type UIDeviceOrientation which has more values thanUIInterfaceOrientation

Since the method expects a UIInterfaceOrientation instead of a UIDeviceOrientation

Replace:

  • supportsOrientation:currentOrientation with
  • supportsOrientation:[[UIApplication sharedApplication] statusBarOrientation]]

Try changing the method in 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
        }
    }
}
jermel
  • 2,326
  • 21
  • 19