【发布时间】:2018-04-29 21:13:55
【问题描述】:
我有两个视图控制器,它们显示一个 mapkit,一个用于具有后退按钮的地点描述。但是每次我尝试隐藏地图注释并转到地点描述然后再次返回到 mapkit 时,它都会使用我尝试隐藏的注释重新加载我的地图。如何防止 mapkit 重新加载其数据但仍隐藏我的地图注释?
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
//1
let coordinate = view.annotation!.coordinate
//2
if let userCoordinate = userLocation {
//3
if userCoordinate.distance(from: CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)) < 30000 {
//4
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if let viewController = storyboard.instantiateViewController(withIdentifier: "ARViewController") as? PlaceViewController {
// more code later
//5
if let mapAnnotation = view.annotation as? MapA {
//6
if(mapAnnotation.title == "New")
{
mapView.view(for: mapAnnotation)?.isHidden = true
self.present(viewController, animated: true, completion: nil)
viewController.adL.text = "TEST"
viewController.descT.text = "Hej"
}
}
【问题讨论】:
标签: swift annotations mapkit