diff options
author | v.mikhaylenko <v.mikhaylenko@corp.mail.ru> | 2015-08-05 21:07:59 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:59:26 +0300 |
commit | c3bbfcbc5c062db520c61f3f8be94b60ccc2562d (patch) | |
tree | a079ae686d4aa001b1e9f01b801f3eeee4e79741 /iphone/Maps/Classes/CustomAlert | |
parent | 71dac84a9ab55b451245b1acb9d84df59f08590d (diff) |
[ios] Fixed alerts on iOS7 && fixed roure disclaimer alert layout.
Diffstat (limited to 'iphone/Maps/Classes/CustomAlert')
3 files changed, 31 insertions, 12 deletions
diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm index f0df31c4e5..c1d1d93737 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm @@ -36,7 +36,7 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController { [UIView animateWithDuration:duration animations:^ { - alert.transform = [self rotationForOrientation:toInterfaceOrientation]; + alert.transform = rotation(toInterfaceOrientation); }]; } if ([alert respondsToSelector:@selector(willRotateToInterfaceOrientation:)]) @@ -127,19 +127,23 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController - (void)displayAlert:(MWMAlert *)alert { + BOOL const iOS7 = isIOSVersionLessThan(8); alert.alertController = self; [self.ownerViewController addChildViewController:self]; self.view.alpha = 0.; alert.alpha = 0.; - CGFloat const scale = 1.1; - alert.transform = CGAffineTransformMakeScale(scale, scale); + if (!iOS7) + { + CGFloat const scale = 1.1; + alert.transform = CGAffineTransformMakeScale(scale, scale); + } self.view.center = self.ownerViewController.view.center; [self.ownerViewController.view addSubview:self.view]; UIWindow * window = [[[UIApplication sharedApplication] delegate] window]; [window addSubview:self.view]; self.view.frame = window.bounds; - if (isIOSVersionLessThan(8)) - alert.transform = [self rotationForOrientation:self.ownerViewController.interfaceOrientation]; + if (iOS7) + alert.transform = rotation(self.ownerViewController.interfaceOrientation); [self.view addSubview:alert]; alert.bounds = self.view.bounds; alert.center = self.view.center; @@ -147,7 +151,8 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController { self.view.alpha = 1.; alert.alpha = 1.; - alert.transform = CGAffineTransformIdentity; + if (!iOS7) + alert.transform = CGAffineTransformIdentity; }]; } @@ -176,7 +181,7 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController [a openURL:url]; } -- (CGAffineTransform)rotationForOrientation:(UIInterfaceOrientation)orientation +CGAffineTransform rotation(UIInterfaceOrientation orientation) { switch (orientation) { diff --git a/iphone/Maps/Classes/CustomAlert/RoutingDisclaimerAlert/MWMRoutingDisclaimerAlert.mm b/iphone/Maps/Classes/CustomAlert/RoutingDisclaimerAlert/MWMRoutingDisclaimerAlert.mm index b0ae3f54a0..23466150de 100644 --- a/iphone/Maps/Classes/CustomAlert/RoutingDisclaimerAlert/MWMRoutingDisclaimerAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/RoutingDisclaimerAlert/MWMRoutingDisclaimerAlert.mm @@ -6,6 +6,7 @@ // Copyright (c) 2015 MapsWithMe. All rights reserved. // +#import "Common.h" #import "MWMAlertViewController.h" #import "MWMRoutingDisclaimerAlert.h" #import "UIColor+MapsMeColor.h" @@ -25,12 +26,25 @@ static CGFloat const kMinimumOffset = 20.; + (instancetype)alertWithInitialOrientation:(UIInterfaceOrientation)orientation { - MWMRoutingDisclaimerAlert * alert = [[[NSBundle mainBundle] loadNibNamed:[MWMRoutingDisclaimerAlert className] owner:nil options:nil] firstObject]; - NSString * message = [NSString stringWithFormat:@"%@\n\n%@\n\n%@\n\n%@", L(@"dialog_routing_disclaimer_priority"), L(@"dialog_routing_disclaimer_precision"), L(@"dialog_routing_disclaimer_recommendations"),L(@"dialog_routing_disclaimer_beware")]; - alert.textView.attributedText = [[NSAttributedString alloc] initWithString:message attributes:@{NSFontAttributeName : UIFont.regular14, NSForegroundColorAttributeName : UIColor.blackSecondaryText}]; + MWMRoutingDisclaimerAlert * alert = [[[NSBundle mainBundle] loadNibNamed:[MWMRoutingDisclaimerAlert className] + owner:nil + options:nil] firstObject]; + NSString * message = [NSString stringWithFormat:@"%@\n\n%@\n\n%@\n\n%@", + L(@"dialog_routing_disclaimer_priority"), + L(@"dialog_routing_disclaimer_precision"), + L(@"dialog_routing_disclaimer_recommendations"), + L(@"dialog_routing_disclaimer_beware")]; + alert.textView.attributedText = [[NSAttributedString alloc] initWithString:message + attributes:@{NSFontAttributeName : UIFont.regular14, + NSForegroundColorAttributeName : UIColor.blackSecondaryText}]; [alert.textView sizeToFit]; UIWindow * window = UIApplication.sharedApplication.keyWindow; - [alert invalidateTextViewHeight:alert.textView.height withHeight:UIInterfaceOrientationIsLandscape(orientation) ? window.width : window.height]; + CGFloat height; + if (isIOSVersionLessThan(8)) + height = UIInterfaceOrientationIsLandscape(orientation) ? window.width : window.height; + else + height = window.height; + [alert invalidateTextViewHeight:alert.textView.height withHeight:height]; return alert; } diff --git a/iphone/Maps/Classes/CustomAlert/RoutingDisclaimerAlert/MWMRoutingDisclaimerAlert.xib b/iphone/Maps/Classes/CustomAlert/RoutingDisclaimerAlert/MWMRoutingDisclaimerAlert.xib index 372d573f9e..5cb41cf618 100644 --- a/iphone/Maps/Classes/CustomAlert/RoutingDisclaimerAlert/MWMRoutingDisclaimerAlert.xib +++ b/iphone/Maps/Classes/CustomAlert/RoutingDisclaimerAlert/MWMRoutingDisclaimerAlert.xib @@ -35,7 +35,7 @@ </label> <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" usesAttributedText="YES" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lbr-Xd-hLF"> <rect key="frame" x="20" y="53" width="240" height="20"/> - <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <constraints> <constraint firstAttribute="width" constant="240" id="GeJ-mk-jko"/> <constraint firstAttribute="height" constant="20" id="XLp-um-S4A"/> |