ios - 如何在呈现 UIViewController 之前预加载 MKMapView?
问题描述
我以模态方式呈现 a UIViewController
,其中包含 a MKMapView
。但UIViewController
仅应在MKMapView
完成加载/渲染特定区域后呈现。所以如果UIViewController
出现了,地图应该已经在那里了。我需要加载它以便在这些UIViewController
. 当然,我UIActivityIndicatorView
向用户展示了一个。
我已经做了什么:
let mapViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "mapView") as! MapViewViewController
let _ = mapViewController.view //viewDidLoad gets called and views are loaded
mapViewController.set(region: Region)
self.mapInfoCard.loadingIndicator.startAnimating()
//called on MKMapView´s mapViewDidFinishLoadingMap(_ mapView: MKMapView) delegate function
mapViewController.finishedHandler = {
self.mapInfoCard.loadingIndicator.stopAnimating()
self.present(mapViewController, animated: true, completion: nil)
}
但从mapViewDidFinishLoadingMap(_ mapView: MKMapView)
未被调用。委托函数在mapView(_ mapView: MKMapView, regionWillChangeAnimated animated: Bool)
我设置区域后被调用,但mapViewWillStartLoadingMap(_ mapView: MKMapView)
或mapViewDidFinishLoadingMap(_ mapView: MKMapView)
从不调用。只有当我呈现的UIViewController
时候,不等死finishedHandler
。
解决方案
推荐阅读
- git - 合并文件及其各自分支的日志
- python - Python:在 Seaborn 中更改/自定义颜色图
- android - 如何从android中另一个HTML文件中的链接打开一个HTML文件?
- selenium - Selenium + Chrome 驱动程序拖放无法正常工作
- java - 在 Heroku 上部署 Gradle 项目
- javascript - 使用 PHP/JS/MYSQL 恢复 ID 或值
- typescript - 在打字稿中覆盖 XMLHttpRequest.prototype.open 失败
- websphere - IBM Websphere 6.1 启动时用户访问受限
- sed - sed:-e 表达式 #1,字符 5:未终止的 `s' 命令
- python - 类方法如何影响 Python 中的实例变量?