From 1e15c9a94bee320e7d0f94ca848dd767df494f3b Mon Sep 17 00:00:00 2001 From: Freek Sanders Date: Tue, 11 Nov 2014 17:12:40 +0100 Subject: [PATCH] Update LMAlertView.m Current implementation rotates the alert view incorrectly in iOS 8 when in landscape mode. Same problem existed in SVProgressHUD. Solution is taken from SVProgressHUD and works. Solution is to check for iOS 8. In that case rotation is applied automagically. --- LMAlertView/LMAlertView.m | 41 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/LMAlertView/LMAlertView.m b/LMAlertView/LMAlertView.m index 2ad40d3..600f4b8 100644 --- a/LMAlertView/LMAlertView.m +++ b/LMAlertView/LMAlertView.m @@ -401,20 +401,33 @@ - (void)transformAlertContainerViewForOrientation{ #define DegreesToRadians(degrees) (degrees * M_PI / 180) UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; CGAffineTransform transform; - switch (orientation) { - case UIInterfaceOrientationLandscapeLeft: - transform = CGAffineTransformMakeRotation(-DegreesToRadians(90)); - break; - case UIInterfaceOrientationLandscapeRight: - transform = CGAffineTransformMakeRotation(DegreesToRadians(90)); - break; - case UIInterfaceOrientationPortraitUpsideDown: - transform = CGAffineTransformMakeRotation(DegreesToRadians(180)); - break; - case UIInterfaceOrientationPortrait: - default: - transform = CGAffineTransformMakeRotation(DegreesToRadians(0)); - break; + + BOOL ignoreOrientation = NO; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) { + ignoreOrientation = YES; + } +#endif + + if (ignoreOrientation) { + transform = CGAffineTransformMakeRotation(DegreesToRadians(0)); + } + else { + switch (orientation) { + case UIInterfaceOrientationLandscapeLeft: + transform = CGAffineTransformMakeRotation(-DegreesToRadians(90)); + break; + case UIInterfaceOrientationLandscapeRight: + transform = CGAffineTransformMakeRotation(DegreesToRadians(90)); + break; + case UIInterfaceOrientationPortraitUpsideDown: + transform = CGAffineTransformMakeRotation(DegreesToRadians(180)); + break; + case UIInterfaceOrientationPortrait: + default: + transform = CGAffineTransformMakeRotation(DegreesToRadians(0)); + break; + } } [self.alertContainerView setTransform:transform];