MotionOrientation icon indicating copy to clipboard operation
MotionOrientation copied to clipboard

Fix use of UIInterfaceOrientation constants

Open rafaelmaroxa opened this issue 10 years ago • 0 comments

According to the documentation, UIDeviceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeLeft are not the same. In fact, they are the exact opposite.

Take a look at the definition of UIInterfaceOrientation:

// Note that UIInterfaceOrientationLandscapeLeft is equal to UIDeviceOrientationLandscapeRight (and vice versa).
// This is because rotating the device to the left requires rotating the content to the right.
typedef NS_ENUM(NSInteger, UIInterfaceOrientation) {
    UIInterfaceOrientationUnknown            = UIDeviceOrientationUnknown,
    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,
    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,
    UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft
};

That being said, I noticed that when newInterfaceOrientation was being calculated in MotionOrientation.m:179 and MotionOrientation.m:197, the constant was not being flipped.

This fix also affected - (CGAffineTransform)affineTransform, which was also fixed.

rafaelmaroxa avatar Sep 24 '14 04:09 rafaelmaroxa