From b407dc4def55d46a7cad4e8294b74ccdf8d20212 Mon Sep 17 00:00:00 2001 From: Aleksey Belousov Date: Mon, 13 Apr 2020 18:16:00 +0300 Subject: [PATCH] [iOS] fix crash in downloader on iPad --- .../Maps/UI/Downloader/DownloadMapsViewController.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift b/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift index aa91787ef1..cb7358b777 100644 --- a/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift +++ b/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift @@ -87,11 +87,13 @@ class DownloadMapsViewController: MWMViewController { navigationController?.pushViewController(vc, animated: true) } - fileprivate func showActions(_ nodeAttrs: MapNodeAttributes) { + fileprivate func showActions(_ nodeAttrs: MapNodeAttributes, in cell: UITableViewCell) { let menuTitle = nodeAttrs.nodeName let multiparent = nodeAttrs.parentInfo.count > 1 let message = dataSource.isRoot || multiparent ? nil : nodeAttrs.parentInfo.first?.countryName let actionSheet = UIAlertController(title: menuTitle, message: message, preferredStyle: .actionSheet) + actionSheet.popoverPresentationController?.sourceView = cell + actionSheet.popoverPresentationController?.sourceRect = cell.bounds let actions: [NodeAction] switch nodeAttrs.nodeStatus { @@ -334,7 +336,7 @@ extension DownloadMapsViewController: UITableViewDelegate { showChildren(dataSource.item(at: indexPath)) return } - showActions(nodeAttrs) + showActions(nodeAttrs, in: tableView.cellForRow(at: indexPath)!) } } @@ -381,7 +383,7 @@ extension DownloadMapsViewController: MWMMapDownloaderTableViewCellDelegate { func mapDownloaderCellDidLongPress(_ cell: MWMMapDownloaderTableViewCell) { guard let indexPath = tableView.indexPath(for: cell) else { return } let nodeAttrs = dataSource.item(at: indexPath) - showActions(nodeAttrs) + showActions(nodeAttrs, in: cell) } }