[ios] Fixed alerts on iOS7 && fixed roure disclaimer alert layout.

This commit is contained in:
v.mikhaylenko 2015-08-05 21:07:59 +03:00 committed by Alex Zolotarev
parent 71dac84a9a
commit c3bbfcbc5c
3 changed files with 31 additions and 12 deletions

View file

@ -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)
{

View file

@ -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;
}

View file

@ -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"/>