From a3d744185be6b8b138e7711b7f267e3c2f669561 Mon Sep 17 00:00:00 2001 From: Alexander Boriskov Date: Wed, 18 Mar 2020 12:43:14 +0300 Subject: [PATCH] [iOS] Merge AdBanner and AdBannerView https://jira.mail.ru/browse/MAPSME-13395 --- iphone/Maps/Bookmarks/BookmarksVC.mm | 2 +- .../Maps/Categories/UITableView+Cells.swift | 6 +- .../MWMDownloadTransitMapAlert.mm | 2 +- .../RouteManagerViewController.swift | 2 +- iphone/Maps/Maps.xcodeproj/project.pbxproj | 12 +- iphone/Maps/UI/Ads/AdBanner.swift | 236 --------------- iphone/Maps/UI/Ads/AdBanner.xib | 269 ------------------ iphone/Maps/UI/Ads/AdBannerCell.swift | 20 ++ iphone/Maps/UI/Ads/AdBannerView.xib | 2 +- .../UI/Discovery/MWMDiscoveryTableManager.mm | 12 +- .../EditBookmark/MWMEditBookmarkController.mm | 6 +- .../Maps/UI/Editor/MWMEditorViewController.mm | 2 +- .../MWMOpeningHoursEditorViewController.mm | 2 +- .../Street/MWMStreetEditorViewController.mm | 2 +- .../PlacePagePreviewViewController.swift | 3 +- iphone/Maps/UI/PlacePage/PlacePage.storyboard | 34 ++- .../UGCAddReview/UGCAddReviewController.swift | 4 +- .../TableView/MWMSearchTableViewController.mm | 8 +- .../SearchCategoriesViewController.swift | 4 +- .../SearchHistoryViewController.swift | 2 +- 20 files changed, 77 insertions(+), 553 deletions(-) delete mode 100644 iphone/Maps/UI/Ads/AdBanner.swift delete mode 100644 iphone/Maps/UI/Ads/AdBanner.xib create mode 100644 iphone/Maps/UI/Ads/AdBannerCell.swift diff --git a/iphone/Maps/Bookmarks/BookmarksVC.mm b/iphone/Maps/Bookmarks/BookmarksVC.mm index 1bddc2fcde..89923d9b4d 100644 --- a/iphone/Maps/Bookmarks/BookmarksVC.mm +++ b/iphone/Maps/Bookmarks/BookmarksVC.mm @@ -216,7 +216,7 @@ using namespace std; [self.noResultsView setTranslatesAutoresizingMaskIntoConstraints:NO]; self.tableView.estimatedRowHeight = 44; - [self.tableView registerWithCellClass:MWMCategoryInfoCell.class]; + [self.tableView registerNibWithCellClass:MWMCategoryInfoCell.class]; auto regularTitleAttributes = @{ NSFontAttributeName: [UIFont regular16], NSForegroundColorAttributeName: [UIColor linkBlue] }; diff --git a/iphone/Maps/Categories/UITableView+Cells.swift b/iphone/Maps/Categories/UITableView+Cells.swift index 1835f6aae5..0e3db70029 100644 --- a/iphone/Maps/Categories/UITableView+Cells.swift +++ b/iphone/Maps/Categories/UITableView+Cells.swift @@ -1,8 +1,12 @@ extension UITableView { - @objc func register(cellClass: AnyClass) { + @objc func registerNib(cellClass: AnyClass) { register(UINib(cellClass), forCellReuseIdentifier: toString(cellClass)) } + @objc func registerClass(cellClass: AnyClass) { + register(cellClass, forCellReuseIdentifier: toString(cellClass)) + } + @objc func dequeueReusableCell(withCellClass cellClass: AnyClass) -> UITableViewCell? { return dequeueReusableCell(withIdentifier: toString(cellClass)) } diff --git a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm index bdb20222c7..6ac9fd01be 100644 --- a/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DownloadTransitMapsAlert/MWMDownloadTransitMapAlert.mm @@ -108,7 +108,7 @@ CGFloat const kAnimationDuration = .05; - (void)configure { - [self.dialogsTableView registerWithCellClass:[MWMDownloaderDialogCell class]]; + [self.dialogsTableView registerNibWithCellClass:[MWMDownloaderDialogCell class]]; self.listExpanded = NO; CALayer * containerViewLayer = self.containerView.layer; containerViewLayer.shouldRasterize = YES; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift index cc0364d85b..6c73341566 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift @@ -186,7 +186,7 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource } private func setupTableView() { - tableView.register(cellClass: RouteManagerCell.self) + tableView.registerNib(cellClass: RouteManagerCell.self) tableView.estimatedRowHeight = 48 tableView.rowHeight = UITableView.automaticDimension } diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index e4f15b53bb..aa28f397bb 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -149,8 +149,7 @@ 3486B5081E27A4B50069C126 /* LocalNotificationManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3486B5061E27A4B50069C126 /* LocalNotificationManager.mm */; }; 3486B50D1E27A6DA0069C126 /* MWMPushNotifications.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3486B50B1E27A6DA0069C126 /* MWMPushNotifications.mm */; }; 3486B5191E27AD3B0069C126 /* MWMFrameworkListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3486B5131E27AD3B0069C126 /* MWMFrameworkListener.mm */; }; - 3488B0131E9D0AEC0068AFD8 /* AdBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3488B0101E9D0AEC0068AFD8 /* AdBanner.swift */; }; - 3488B0161E9D0AEC0068AFD8 /* AdBanner.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3488B0111E9D0AEC0068AFD8 /* AdBanner.xib */; }; + 3488B0131E9D0AEC0068AFD8 /* AdBannerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3488B0101E9D0AEC0068AFD8 /* AdBannerCell.swift */; }; 3488B01A1E9D0B230068AFD8 /* UIColor+Modifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3488B0181E9D0B230068AFD8 /* UIColor+Modifications.swift */; }; 3488B03B1E9D13EF0068AFD8 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3488B03A1E9D13EF0068AFD8 /* UserNotifications.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 348A8DF51F66775A00D83026 /* RatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 348A8DF11F66775A00D83026 /* RatingView.swift */; }; @@ -1101,8 +1100,7 @@ 3486B5121E27AD3B0069C126 /* MWMFrameworkListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMFrameworkListener.h; sourceTree = ""; }; 3486B5131E27AD3B0069C126 /* MWMFrameworkListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMFrameworkListener.mm; sourceTree = ""; }; 3486B5141E27AD3B0069C126 /* MWMFrameworkObservers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMFrameworkObservers.h; sourceTree = ""; }; - 3488B0101E9D0AEC0068AFD8 /* AdBanner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdBanner.swift; sourceTree = ""; }; - 3488B0111E9D0AEC0068AFD8 /* AdBanner.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AdBanner.xib; sourceTree = ""; }; + 3488B0101E9D0AEC0068AFD8 /* AdBannerCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdBannerCell.swift; sourceTree = ""; }; 3488B0181E9D0B230068AFD8 /* UIColor+Modifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Modifications.swift"; sourceTree = ""; }; 3488B03A1E9D13EF0068AFD8 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; }; 348A8DF11F66775A00D83026 /* RatingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RatingView.swift; sourceTree = ""; }; @@ -2626,10 +2624,9 @@ 3432E17F1E49BEFA008477E9 /* Ads */ = { isa = PBXGroup; children = ( - 3488B0101E9D0AEC0068AFD8 /* AdBanner.swift */, - 3488B0111E9D0AEC0068AFD8 /* AdBanner.xib */, 474AC76A2139E4F2002F9BF9 /* RemoveAdsViewController.swift */, 474AC76B2139E4F2002F9BF9 /* RemoveAdsViewController.xib */, + 3488B0101E9D0AEC0068AFD8 /* AdBannerCell.swift */, 4738A8E6239FC513007C0F43 /* AdBannerView.swift */, 4738A8E8239FC526007C0F43 /* AdBannerView.xib */, ); @@ -5046,7 +5043,6 @@ F6E2FF001E097BA00083EBEC /* SearchCategoryCell.xib in Resources */, F6E2FF331E097BA00083EBEC /* MWMSearchCommonCell.xib in Resources */, F6E2FF061E097BA00083EBEC /* SearchHistoryClearCell.xib in Resources */, - 3488B0161E9D0AEC0068AFD8 /* AdBanner.xib in Resources */, BB7626B61E85599C0031D71C /* icudt57l.dat in Resources */, 34AB665C1FC5AA330078E451 /* TransportTransitIntermediatePoint.xib in Resources */, F6E2FF151E097BA00083EBEC /* SearchHistoryQueryCell.xib in Resources */, @@ -5581,7 +5577,7 @@ 993DF12923F6BDB100AC231A /* ThemeManager.swift in Sources */, 337F98A621D37B7400C8AC27 /* SearchTabViewController.swift in Sources */, 479D306122C6634900D18278 /* MWMMegafonBannerViewController.m in Sources */, - 3488B0131E9D0AEC0068AFD8 /* AdBanner.swift in Sources */, + 3488B0131E9D0AEC0068AFD8 /* AdBannerCell.swift in Sources */, 3404755F1E081A4600C92850 /* MWMLocationPredictor.mm in Sources */, 993DF11523F6BDB100AC231A /* UISearchBarRenderer.swift in Sources */, F6E2FE041E097BA00083EBEC /* MWMOpeningHoursDaysSelectorTableViewCell.mm in Sources */, diff --git a/iphone/Maps/UI/Ads/AdBanner.swift b/iphone/Maps/UI/Ads/AdBanner.swift deleted file mode 100644 index 827aa8a521..0000000000 --- a/iphone/Maps/UI/Ads/AdBanner.swift +++ /dev/null @@ -1,236 +0,0 @@ -import FBAudienceNetwork -import MoPub_FacebookAudienceNetwork_Adapters - -private func attributedTitle(title: String, indent: CGFloat) -> NSAttributedString { - let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.firstLineHeadIndent = indent - paragraphStyle.lineBreakMode = .byTruncatingTail - return NSAttributedString(string: title, - attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle, - NSAttributedString.Key.font: UIFont.bold12(), - NSAttributedString.Key.foregroundColor: UIColor.blackSecondaryText() - ]) -} - -@objc(MWMAdBanner) -final class AdBanner: UITableViewCell { - @IBOutlet private var detailedModeConstraints: [NSLayoutConstraint]! - @IBOutlet private weak var adCallToActionButtonCompactLeading: NSLayoutConstraint! - @IBOutlet private weak var adIconImageView: UIImageView! - @IBOutlet private weak var adTitleLabel: UILabel! - @IBOutlet private weak var adBodyLabel: UILabel! - @IBOutlet private weak var DAAImage: UIImageView! - @IBOutlet private weak var DAAImageWidth: NSLayoutConstraint! - @IBOutlet private weak var adPrivacyImage: UIImageView! - @IBOutlet private weak var adCallToActionButtonCompact: UIButton! - @IBOutlet private weak var adCallToActionButtonDetailed: UIButton! - @IBOutlet private weak var adCallToActionButtonCustom: UIButton! - @IBOutlet private weak var removeAdsSmallButton: UIButton! - @IBOutlet private weak var removeAdsLargeButton: UIButton! - @IBOutlet private weak var removeAdsImage: UIImageView! - @IBOutlet private weak var fallbackAdView: UIView! - @IBOutlet private var nativeAdViewBottom: NSLayoutConstraint! - @IBOutlet private var fallbackAdViewBottom: NSLayoutConstraint! - @IBOutlet private var fallbackAdViewHeight: NSLayoutConstraint! - @IBOutlet private var ctaButtonLeftConstraint: NSLayoutConstraint! - @IBOutlet private weak var nativeAdView: UIView! { - didSet { - nativeAdView.layer.borderColor = UIColor.blackDividers().cgColor - } - } - - @objc var onRemoveAds: MWMVoidBlock? - - @objc static let detailedBannerExcessHeight: Float = 52 - - enum AdType { - case native - case fallback - } - - var adType = AdType.native { - didSet { - let isNative = adType == .native - nativeAdView.isHidden = !isNative - fallbackAdView.isHidden = isNative - - nativeAdViewBottom.isActive = isNative - fallbackAdViewBottom.isActive = !isNative - fallbackAdViewHeight.isActive = !isNative - } - } - - @objc var state = AdBannerState.unset { - didSet { - guard state != .unset else { - adCallToActionButtonCustom.isHidden = true - mpNativeAd = nil - nativeAd = nil - return - } - guard state != oldValue else { return } - let config = state.config() - animateConstraints(animations: { - self.adTitleLabel.numberOfLines = config.numberOfTitleLines - self.adBodyLabel.numberOfLines = config.numberOfBodyLines - self.detailedModeConstraints.forEach { $0.priority = config.priority } - self.refreshBannerIfNeeded() - }) - } - } - - @objc weak var mpNativeAd: MPNativeAd? - - override func prepareForReuse() { - super.prepareForReuse() - adIconImageView.wi_cancelImageRequest() - adIconImageView.image = nil; - } - - private var nativeAd: Banner? { - willSet { - nativeAd?.unregister() - } - } - - @IBAction - private func privacyAction() { - let url: URL? - if let ad = nativeAd as? FacebookBanner { - url = ad.nativeAd.adChoicesLinkURL - } else if let ad = nativeAd as? MopubBanner, let u = ad.privacyInfoURL { - url = u - } else { - return - } - - UIViewController.topViewController().open(url) - } - - @IBAction - private func removeAction(_ sender: UIButton) { - Statistics.logEvent(kStatInappBannerClose, withParameters: [ - kStatBanner : state == .detailed ? 1 : 0, - kStatButton : sender == removeAdsLargeButton ? 1 : 0]) - onRemoveAds?() - } - - func reset() { - state = .unset - } - - @objc func config(ad: MWMBanner, containerType: AdBannerContainerType, canRemoveAds: Bool, onRemoveAds: (() -> Void)?) { - reset() - switch containerType { - case .placePage: - state = alternative(iPhone: .compact, iPad: .detailed) - case .search: - state = .search - } - - nativeAd = ad as? Banner - switch ad { - case let ad as FacebookBanner: configFBBanner(ad: ad.nativeAd) - case let ad as RBBanner: configRBBanner(ad: ad) - case let ad as MopubBanner: configMopubBanner(ad: ad) - default: assert(false) - } - self.onRemoveAds = onRemoveAds - removeAdsSmallButton.isHidden = !canRemoveAds - removeAdsLargeButton.isHidden = !canRemoveAds - removeAdsImage.isHidden = !canRemoveAds - ctaButtonLeftConstraint.priority = canRemoveAds ? .defaultLow : .defaultHigh - } - - override func setHighlighted(_ highlighted: Bool, animated: Bool) { - adCallToActionButtonCompact.isHighlighted = highlighted; - adCallToActionButtonDetailed.isHighlighted = highlighted; - } - - private func configFBBanner(ad: FBNativeBannerAd) { - adType = .native - DAAImageWidth.constant = adPrivacyImage.width; - DAAImage.isHidden = false; - - let adCallToActionButtons: [UIView] - if state == .search { - adCallToActionButtons = [self, adCallToActionButtonCompact] - } else { - adCallToActionButtons = [adCallToActionButtonCompact, adCallToActionButtonDetailed] - } - ad.registerView(forInteraction: self, - iconImageView: adIconImageView, - viewController: UIViewController.topViewController(), - clickableViews: adCallToActionButtons) - - adTitleLabel.attributedText = attributedTitle(title: ad.headline ?? "", - indent: adPrivacyImage.width + DAAImageWidth.constant) - adBodyLabel.text = ad.bodyText ?? "" - let config = state.config() - adTitleLabel.numberOfLines = config.numberOfTitleLines - adBodyLabel.numberOfLines = config.numberOfBodyLines - [adCallToActionButtonCompact, adCallToActionButtonDetailed].forEach { $0.setTitle(ad.callToAction, for: .normal) } - } - - private func configRBBanner(ad: MTRGNativeAd) { - guard let banner = ad.banner else { return } - adType = .native - DAAImageWidth.constant = 0; - DAAImage.isHidden = true; - - MTRGNativeAd.loadImage(banner.icon, to: adIconImageView) - adTitleLabel.attributedText = attributedTitle(title: banner.title, - indent: adPrivacyImage.width + DAAImageWidth.constant) - adBodyLabel.text = banner.descriptionText ?? "" - let config = state.config() - adTitleLabel.numberOfLines = config.numberOfTitleLines - adBodyLabel.numberOfLines = config.numberOfBodyLines - - [adCallToActionButtonCompact, adCallToActionButtonDetailed].forEach { $0.setTitle(banner.ctaText, for: .normal) } - refreshBannerIfNeeded() - } - - private func configMopubBanner(ad: MopubBanner) { - mpNativeAd = ad.nativeAd - adType = .native - - DAAImageWidth.constant = adPrivacyImage.width; - DAAImage.isHidden = false; - - let adCallToActionButtons: [UIButton] - if state == .search { - adCallToActionButtonCustom.isHidden = false - adCallToActionButtons = [adCallToActionButtonCustom, adCallToActionButtonCompact] - } else { - adCallToActionButtons = [adCallToActionButtonCompact, adCallToActionButtonDetailed] - adCallToActionButtons.forEach { $0.setTitle(ad.ctaText, for: .normal) } - } - mpNativeAd?.setAdView(self, iconView: adIconImageView, actionButtons: adCallToActionButtons) - adTitleLabel.attributedText = attributedTitle(title: ad.title, - indent: adPrivacyImage.width + DAAImageWidth.constant) - adBodyLabel.text = ad.text - if let url = URL(string: ad.iconURL) { - adIconImageView.wi_setImage(with: url) - } - } - - private func refreshBannerIfNeeded() { - if let ad = nativeAd as? MTRGNativeAd { - let clickableView: UIView - switch state { - case .unset: - assert(false) - clickableView = adCallToActionButtonCompact - case .compact: clickableView = adCallToActionButtonCompact - case .detailed: clickableView = adCallToActionButtonDetailed - case .search: clickableView = self - } - ad.register(clickableView, with: UIViewController.topViewController()) - } - } - - override func willMove(toSuperview newSuperview: UIView?) { - super.willMove(toSuperview: newSuperview) - mpNativeAd?.nativeViewWillMove(toSuperview: newSuperview) - } -} diff --git a/iphone/Maps/UI/Ads/AdBanner.xib b/iphone/Maps/UI/Ads/AdBanner.xib deleted file mode 100644 index a36a484cc9..0000000000 --- a/iphone/Maps/UI/Ads/AdBanner.xib +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/UI/Ads/AdBannerCell.swift b/iphone/Maps/UI/Ads/AdBannerCell.swift new file mode 100644 index 0000000000..171912c92e --- /dev/null +++ b/iphone/Maps/UI/Ads/AdBannerCell.swift @@ -0,0 +1,20 @@ +@objc(MWMAdBannerCell) +final class AdBannerCell: UITableViewCell { + private let adBannerView: AdBannerView + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + adBannerView = Bundle.main.load(viewClass: AdBannerView.self)?.first as! AdBannerView + super.init(style: style, reuseIdentifier: reuseIdentifier) + adBannerView.frame = self.bounds + addSubview(adBannerView) + clipsToBounds = true + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @objc func config(ad: MWMBanner, containerType: AdBannerContainerType, canRemoveAds: Bool, onRemoveAds: (() -> Void)?) { + adBannerView.config(ad: ad, containerType: containerType, canRemoveAds: canRemoveAds, onRemoveAds: onRemoveAds) + } +} diff --git a/iphone/Maps/UI/Ads/AdBannerView.xib b/iphone/Maps/UI/Ads/AdBannerView.xib index 22fde1cde9..148d8555c5 100644 --- a/iphone/Maps/UI/Ads/AdBannerView.xib +++ b/iphone/Maps/UI/Ads/AdBannerView.xib @@ -99,7 +99,7 @@ - + + + + + @@ -489,6 +496,7 @@ + diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCAddReview/UGCAddReviewController.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCAddReview/UGCAddReviewController.swift index 90b3a7f766..b4a55d34a7 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCAddReview/UGCAddReviewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCAddReview/UGCAddReviewController.swift @@ -54,8 +54,8 @@ final class UGCAddReviewController: MWMTableViewController { } private func configTableView() { - tableView.register(cellClass: UGCAddReviewRatingCell.self) - tableView.register(cellClass: UGCAddReviewTextCell.self) + tableView.registerNib(cellClass: UGCAddReviewRatingCell.self) + tableView.registerNib(cellClass: UGCAddReviewTextCell.self) tableView.estimatedRowHeight = 48 tableView.rowHeight = UITableView.automaticDimension diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm index 5747125e79..72527edf05 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm +++ b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm @@ -57,9 +57,9 @@ NSString * GetLocalizedTypeName(search::Result const & result) UITableView * tableView = self.tableView; tableView.estimatedRowHeight = 80.; tableView.rowHeight = UITableViewAutomaticDimension; - [tableView registerWithCellClass:[MWMSearchSuggestionCell class]]; - [tableView registerWithCellClass:[MWMSearchCommonCell class]]; - [tableView registerWithCellClass:[MWMAdBanner class]]; + [tableView registerNibWithCellClass:[MWMSearchSuggestionCell class]]; + [tableView registerNibWithCellClass:[MWMSearchCommonCell class]]; + [tableView registerClassWithCellClass:[MWMAdBannerCell class]]; } - (void)reloadData { [self.tableView reloadData]; } @@ -112,7 +112,7 @@ NSString * GetLocalizedTypeName(search::Result const & result) case MWMSearchItemTypeMopub: case MWMSearchItemTypeFacebook: { - auto cell = static_cast([tableView dequeueReusableCellWithCellClass:[MWMAdBanner class] indexPath:indexPath]); + auto cell = static_cast([tableView dequeueReusableCellWithCellClass:[MWMAdBannerCell class] indexPath:indexPath]); auto ad = [MWMSearch adWithContainerIndex:containerIndex]; [cell configWithAd:ad containerType:MWMAdBannerContainerTypeSearch diff --git a/iphone/Maps/UI/Search/Tabs/CategoriesTab/SearchCategoriesViewController.swift b/iphone/Maps/UI/Search/Tabs/CategoriesTab/SearchCategoriesViewController.swift index 5ddbb9ab74..346a55b18c 100644 --- a/iphone/Maps/UI/Search/Tabs/CategoriesTab/SearchCategoriesViewController.swift +++ b/iphone/Maps/UI/Search/Tabs/CategoriesTab/SearchCategoriesViewController.swift @@ -26,8 +26,8 @@ final class SearchCategoriesViewController: MWMTableViewController { override func viewDidLoad() { super.viewDidLoad() - tableView.register(cellClass: SearchCategoryCell.self) - tableView.register(cellClass: SearchBannerCell.self) + tableView.registerNib(cellClass: SearchCategoryCell.self) + tableView.registerNib(cellClass: SearchBannerCell.self) tableView.separatorStyle = .none tableView.keyboardDismissMode = .onDrag } diff --git a/iphone/Maps/UI/Search/Tabs/HistoryTab/SearchHistoryViewController.swift b/iphone/Maps/UI/Search/Tabs/HistoryTab/SearchHistoryViewController.swift index 71ac0f4e1a..e05b0a7659 100644 --- a/iphone/Maps/UI/Search/Tabs/HistoryTab/SearchHistoryViewController.swift +++ b/iphone/Maps/UI/Search/Tabs/HistoryTab/SearchHistoryViewController.swift @@ -29,7 +29,7 @@ final class SearchHistoryViewController: MWMViewController { if frameworkHelper.isSearchHistoryEmpty() { showNoResultsView() } else { - tableView.register(cellClass: SearchHistoryQueryCell.self) + tableView.registerNib(cellClass: SearchHistoryQueryCell.self) let nib = UINib(nibName: "SearchHistoryClearCell", bundle: nil) tableView.register(nib, forCellReuseIdentifier: SearchHistoryViewController.clearCellIdentifier) }