diff options
author | Ilya Grechuhin <i.grechuhin@gmail.com> | 2017-11-14 11:57:48 +0300 |
---|---|---|
committer | Roman Kuznetsov <r.kuznetsow@gmail.com> | 2017-11-14 12:38:41 +0300 |
commit | 20491c279e27e2a19b185a40084e339fcdbf825c (patch) | |
tree | 12d6abf4b2e13279e1dc9cb38378876ad44e3c57 /iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC | |
parent | 496b520b67cdb670eee4c0371e1b18fd530db803 (diff) |
[cherry] [MAPSME-5973] [ios] Fixed iOS 9 layout crash.
Diffstat (limited to 'iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC')
3 files changed, 13 insertions, 37 deletions
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingCell.swift index e55ecd9ab4..2d3a4bdc91 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingCell.swift @@ -1,11 +1,5 @@ @objc(MWMUGCSummaryRatingCell) final class UGCSummaryRatingCell: MWMTableViewCell { - private enum Config { - static let minimumInteritemSpacing: CGFloat = 16 - static let minItemsPerRow: CGFloat = 3 - static let estimatedItemSize = CGSize(width: 96, height: 32) - } - @IBOutlet private weak var titleLabel: UILabel! { didSet { titleLabel.font = UIFont.bold22() @@ -37,8 +31,6 @@ final class UGCSummaryRatingCell: MWMTableViewCell { @IBOutlet private weak var ratingCollectionView: UICollectionView! { didSet { ratingCollectionView.register(cellClass: UGCSummaryRatingStarsCell.self) - let layout = ratingCollectionView.collectionViewLayout as! UICollectionViewFlowLayout - layout.estimatedItemSize = Config.estimatedItemSize } } @@ -47,7 +39,7 @@ final class UGCSummaryRatingCell: MWMTableViewCell { override var frame: CGRect { didSet { if frame.size != oldValue.size { - updateCollectionView(nil) + updateCollectionView() } } } @@ -57,34 +49,19 @@ final class UGCSummaryRatingCell: MWMTableViewCell { ratingSummaryView.value = summaryRating.value ratingSummaryView.type = summaryRating.type self.ratings = ratings - updateCollectionView { [weak self] in - self?.ratingCollectionView.reloadSections(IndexSet(integer: 0)) - } + updateCollectionView() isSeparatorHidden = true } override func didMoveToSuperview() { super.didMoveToSuperview() - updateCollectionView(nil) + updateCollectionView() } - private func updateCollectionView(_ updates: (() -> Void)?) { - guard let sv = superview else { return } - let layout = ratingCollectionView.collectionViewLayout as! UICollectionViewFlowLayout - let inset = layout.sectionInset - let viewWidth = sv.size.width - inset.left - inset.right - let maxItemWidth = layout.estimatedItemSize.width - - let ratingsCount = CGFloat(ratings?.count ?? 0) - let itemsPerRow = floor(min(max(viewWidth / maxItemWidth, Config.minItemsPerRow), ratingsCount)) - let itemWidth = floor(min((viewWidth - (itemsPerRow - 1) * Config.minimumInteritemSpacing) / itemsPerRow, maxItemWidth)) - let interitemSpacing = floor((viewWidth - itemWidth * itemsPerRow) / (itemsPerRow - 1)) - layout.minimumInteritemSpacing = interitemSpacing - layout.itemSize = CGSize(width: itemWidth, height: Config.estimatedItemSize.height) - - let rowsCount = ceil(ratingsCount / itemsPerRow) - ratingCollectionViewHeight.constant = rowsCount * Config.estimatedItemSize.height + (rowsCount - 1) * layout.minimumLineSpacing + inset.top + inset.bottom - ratingCollectionView.performBatchUpdates(updates, completion: nil) + private func updateCollectionView() { + DispatchQueue.main.async { + self.ratingCollectionView.reloadData() + } } } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingCell.xib index 61b03d5e50..92b9377622 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingCell.xib +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSummaryRatingCell.xib @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> @@ -73,13 +73,13 @@ <constraint firstItem="vuk-Pr-u1F" firstAttribute="leading" secondItem="MSt-Fx-y5y" secondAttribute="leading" constant="16" id="ykf-u3-iXH"/> </constraints> </view> - <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" prefetchingEnabled="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ek3-Zj-cfu"> + <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" pagingEnabled="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" prefetchingEnabled="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ek3-Zj-cfu"> <rect key="frame" x="0.0" y="78" width="320" height="55.5"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <constraints> <constraint firstAttribute="height" priority="999" constant="56" id="NOt-1H-Ou6"/> </constraints> - <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="12" minimumInteritemSpacing="16" id="liK-AI-Noj"> + <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="12" minimumInteritemSpacing="16" id="liK-AI-Noj"> <size key="itemSize" width="120" height="32"/> <size key="headerReferenceSize" width="0.0" height="0.0"/> <size key="footerReferenceSize" width="0.0" height="0.0"/> diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib index 513045e878..97df13396e 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> @@ -91,7 +91,6 @@ </view> </subviews> <constraints> - <constraint firstItem="w6j-GC-6Bv" firstAttribute="top" secondItem="M3q-L0-4Y7" secondAttribute="bottom" id="14p-0F-Of5"/> <constraint firstItem="l8v-v7-2Xf" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="77N-Z4-HEp"/> <constraint firstItem="w6j-GC-6Bv" firstAttribute="top" secondItem="M3q-L0-4Y7" secondAttribute="bottom" id="L8X-HU-Nlw"/> <constraint firstItem="M3q-L0-4Y7" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="T9p-nW-wRb"/> |