1

In this line: [self deviceInterfaceOrientationChanged:interfaceOrientation];

I get this warning

Implicit conversion from enumeration type ' UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'?

Can u help me ?please. thank u

Here's the code:

     -(void) receivedRotate: (NSNotification*) notification
{
    NSLog(@"receivedRotate");
    UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

    if(interfaceOrientation != UIDeviceOrientationUnknown) {
        [self deviceInterfaceOrientationChanged:interfaceOrientation];


    } else {
        NSLog(@"Unknown device orientation");
    }
}
Larry Morries
  • 669
  • 7
  • 17
  • Refer to the following post. It answers it perfectly. [StackOverFlow Post][1] [1]: http://stackoverflow.com/questions/7015709/xcode-getting-warning-implicit-coversion-from-enumeration-type-uideviceorienta – georryan Oct 28 '11 at 22:08

1 Answers1

0

UIDeviceOrientation and UIInterfaceOrientation are different types, the first is the device orientation and includes other states like Face up or Face Down among others, while the second only covers 2D states, like Portrait and Landscape.

Don't get the device orientation from the device but from the status bar like this:

[[UIApplication sharedApplication] statusBarOrientation] 

This method will return a UIInterfaceOrientation value and the problem will go away.

Raul Huerta
  • 350
  • 1
  • 8
  • viewWillTransitionToSize doesn't rely on orientation but on how the size of you app view will be changed after a certain event, which abstract the use of orientation and could possibly include other kind of events too. Using any kind of orientation code there would be wrong if you want to follow that paradigm. – Raul Huerta Apr 20 '15 at 21:55