[ios] Fixed PP description display.

This commit is contained in:
Ilya Grechuhin 2015-07-27 14:30:40 +03:00 committed by Alex Zolotarev
parent ac13b9b9ef
commit 3aed797094
3 changed files with 45 additions and 35 deletions

View file

@ -14,7 +14,6 @@
#import "UIViewController+Navigation.h"
static NSString * const kBookmarkDescriptionViewControllerNibName = @"MWMBookmarkDescriptionViewController";
static CGFloat const kIpadPlacePageDefaultHeight = 288.;
typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
{
@ -83,10 +82,6 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
return;
[self.iPadOwnerNavigationController setNavigationBarHidden:NO];
CGFloat const bottomOffset = 12.;
self.iPadOwnerNavigationController.view.height = kIpadPlacePageDefaultHeight;
self.textView.height = kIpadPlacePageDefaultHeight - bottomOffset;
self.webView.height = kIpadPlacePageDefaultHeight - bottomOffset;
}
- (void)setState:(BookmarkDescriptionState)state
@ -109,6 +104,8 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
- (void)setupForEditingWithText:(NSString *)text
{
self.textView.hidden = NO;
self.textView.text = text;
[UIView animateWithDuration:0.2f animations:^
{
self.webView.alpha = 0.;
@ -116,13 +113,15 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
}
completion:^(BOOL finished)
{
self.textView.text = text;
self.webView.hidden = YES;
}];
[self configureNavigationBarForEditing];
}
- (void)setupForViewWithText:(NSString *)text
{
self.webView.hidden = NO;
[self.webView loadHTMLString:text baseURL:nil];
[UIView animateWithDuration:0.2f animations:^
{
self.webView.alpha = 1.;
@ -130,7 +129,7 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState)
}
completion:^(BOOL finished)
{
[self.webView loadHTMLString:text baseURL:nil];
self.textView.hidden = YES;
}];
[self configureNavigationBarForView];
}

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MWMBookmarkDescriptionViewController">
@ -13,13 +13,12 @@
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="SolidTouchView">
<rect key="frame" x="0.0" y="64" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" alpha="0.0" contentMode="scaleToFill" id="24o-IB-Pbl" customClass="MWMTextView">
<rect key="frame" x="10" y="5" width="300" height="494"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" alpha="0.0" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="24o-IB-Pbl" customClass="MWMTextView">
<rect key="frame" x="20" y="5" width="280" height="543"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" red="0.12941176470588237" green="0.12941176470588237" blue="0.12941176470588237" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="17"/>
@ -28,9 +27,8 @@
<userDefinedRuntimeAttribute type="string" keyPath="localizedPlaceholder" value="description"/>
</userDefinedRuntimeAttributes>
</textView>
<webView alpha="0.0" contentMode="scaleToFill" id="lov-Ku-GJM">
<rect key="frame" x="10" y="69" width="300" height="494"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<webView alpha="0.0" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lov-Ku-GJM">
<rect key="frame" x="20" y="5" width="280" height="543"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<dataDetectorType key="dataDetectorTypes" phoneNumber="YES" link="YES"/>
<connections>
@ -39,6 +37,16 @@
</webView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="24o-IB-Pbl" secondAttribute="trailing" constant="20" symbolic="YES" id="0yD-gW-2U7"/>
<constraint firstAttribute="bottom" secondItem="lov-Ku-GJM" secondAttribute="bottom" constant="20" symbolic="YES" id="8Nl-2m-geo"/>
<constraint firstAttribute="trailing" secondItem="lov-Ku-GJM" secondAttribute="trailing" constant="20" symbolic="YES" id="9c0-pP-yI9"/>
<constraint firstItem="lov-Ku-GJM" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="5" id="JRG-vj-DBO"/>
<constraint firstItem="24o-IB-Pbl" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="5" id="Vv0-cX-1d3"/>
<constraint firstAttribute="bottom" secondItem="24o-IB-Pbl" secondAttribute="bottom" constant="20" symbolic="YES" id="fvC-Lz-Wl4"/>
<constraint firstItem="24o-IB-Pbl" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="ss4-MI-ZOa"/>
<constraint firstItem="lov-Ku-GJM" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="wSL-73-MXz"/>
</constraints>
<nil key="simulatedTopBarMetrics"/>
<point key="canvasLocation" x="303" y="292"/>
</view>

View file

@ -9,8 +9,6 @@
#import "MWMTextView.h"
#import "Common.h"
static CGFloat const kDefaultTextLeftInset = 5.;
@interface MWMTextView ()
@property (nonatomic) UILabel * placeholderView;
@ -23,7 +21,7 @@ static CGFloat const kDefaultTextLeftInset = 5.;
{
self = [super initWithCoder:coder];
if (self)
[self preparePlaceholder];
[self prepare];
return self;
}
@ -32,24 +30,13 @@ static CGFloat const kDefaultTextLeftInset = 5.;
{
self = [super initWithFrame:frame textContainer:textContainer];
if (self)
[self preparePlaceholder];
[self prepare];
return self;
}
- (void)preparePlaceholder
- (void)prepare
{
NSAssert(!self.placeholderView, @"placeholder has been prepared already: %@", self.placeholderView);
self.placeholderView = [[UILabel alloc] initWithFrame:self.bounds];
self.placeholderView.opaque = NO;
self.placeholderView.backgroundColor = [UIColor clearColor];
self.placeholderView.textColor = [UIColor lightGrayColor];
self.placeholderView.textAlignment = self.textAlignment;
self.placeholderView.userInteractionEnabled = NO;
self.placeholderView.font = self.font;
self.placeholderView.isAccessibilityElement = NO;
[self setTextContainerInset:UIEdgeInsetsZero];
[self updatePlaceholderVisibility];
@ -60,6 +47,23 @@ static CGFloat const kDefaultTextLeftInset = 5.;
self.clipsToBounds = YES;
}
- (UILabel *)placeholderView
{
if (!_placeholderView)
{
_placeholderView = [[UILabel alloc] initWithFrame:self.bounds];
_placeholderView.opaque = NO;
_placeholderView.backgroundColor = [UIColor clearColor];
_placeholderView.textColor = [UIColor lightGrayColor];
_placeholderView.textAlignment = self.textAlignment;
_placeholderView.userInteractionEnabled = NO;
_placeholderView.font = self.font;
_placeholderView.isAccessibilityElement = NO;
_placeholderView.numberOfLines = 0;
}
return _placeholderView;
}
#pragma mark - Setters
- (void)setPlaceholder:(NSString *)placeholder
@ -95,7 +99,6 @@ static CGFloat const kDefaultTextLeftInset = 5.;
- (void)setTextContainerInset:(UIEdgeInsets)textContainerInset
{
textContainerInset.left -= kDefaultTextLeftInset;
[super setTextContainerInset:textContainerInset];
[self updatePlaceholderInset:textContainerInset];
}
@ -108,7 +111,6 @@ static CGFloat const kDefaultTextLeftInset = 5.;
- (void)resizePlaceholderFrame
{
self.placeholderView.numberOfLines = 0;
[self.placeholderView sizeToFit];
}
@ -119,7 +121,8 @@ static CGFloat const kDefaultTextLeftInset = 5.;
- (void)updatePlaceholderInset:(UIEdgeInsets)inset
{
self.placeholderView.frame = CGRectMake(inset.left + kDefaultTextLeftInset, inset.top, self.bounds.size.width - inset.right, self.bounds.size.height - inset.bottom);
CGFloat const kDefaultPlaceholderLeftInset = 5.0;
self.placeholderView.frame = CGRectMake(inset.left + kDefaultPlaceholderLeftInset, inset.top, self.bounds.size.width - inset.right, self.bounds.size.height - inset.bottom);
[self resizePlaceholderFrame];
}