-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure UIAlertViews are always rendered vertically (#2652)
WoCDisplayMode uses a 'presentationTransform' to rotate the presentation surface for certan apps, but we don't want to use that transform to rotate UIAlertViews (else they render sideways if the app is rotated). This will be handled automatically when we move UIAlertView over Xaml (as we've already done for UIActionSheet), but for now we need to undo the 'presentationTransform' rotation for UIAlertViews. Fixes #2611.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
#import <UIKit/UILabel.h> | ||
#import <UIKit/UIScreen.h> | ||
#import <UIKit/UIView.h> | ||
#import <UIKit/UIWindow.h> | ||
|
||
#import <Foundation/NSString.h> | ||
#import <Foundation/NSMutableArray.h> | ||
|
@@ -396,6 +397,32 @@ - (BOOL)isVisible { | |
return alertPriv->_isVisible; | ||
} | ||
|
||
- (void) _handleRotation { | ||
// We need to offset the 'presentationTransform' used in WOCDispalyMode, because we always want to render alerts vertically. | ||
// TODO: We'll remove this when we switch UIAlertView over to a Xaml ContentDialog, since rotation will be handled for us. | ||
const float c_angleToRadian = kPi / 180.0; | ||
switch ([[UIApplication displayMode] presentationTransform]) { | ||
case UIInterfaceOrientationLandscapeRight: | ||
[self setTransform:CGAffineTransformMakeRotation(-static_cast<float>(DisplayProperties::ScreenRotation90Clockwise) * c_angleToRadian)]; | ||
break; | ||
|
||
case UIInterfaceOrientationPortrait: | ||
[self setTransform:CGAffineTransformMakeTranslation(0.0f, 0.0f)]; | ||
break; | ||
|
||
case UIInterfaceOrientationLandscapeLeft: | ||
[self setTransform:CGAffineTransformMakeRotation(-static_cast<float>(DisplayProperties::ScreenRotation90CounterClockwise) * c_angleToRadian)]; | ||
break; | ||
|
||
case UIInterfaceOrientationPortraitUpsideDown: | ||
[self setTransform:CGAffineTransformMakeRotation(-static_cast<float>(DisplayProperties::ScreenRotation180) * c_angleToRadian)]; | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
/** | ||
@Status Interoperable | ||
*/ | ||
|
@@ -550,6 +577,9 @@ - (BOOL)isVisible { | |
frame.size.height = curHeight; | ||
[self initWithFrame:frame]; | ||
|
||
// Make sure we're not rotated even if WOCDisplayMode rotates the presentation surface | ||
[self _handleRotation]; | ||
|
||
id image; | ||
image = [[UIImage imageNamed:@"/img/[email protected]"] stretchableImageWithLeftCapWidth:25 topCapHeight:30]; | ||
UIImageSetLayerContents([self layer], image); | ||
|