2015-10-08 26 views
0

一个动作,我想做一个动作时,地图上移动时,我尝试这个功能,但它不工作:办时,地图移动

func mapView(mapView: MKMapView, regionWillChangeAnimated animated: Bool) { 
    let alert = UIAlertView() 
    alert.title = "Hey" 
    alert.message = "Map Move" 
    alert.addButtonWithTitle("Working!!") 
    alert.show() 
} 

回答

0

你设置mapView.delegate?如果不是这样,则不调用regionWillChangeAnimated方法。

示例。

override func viewDidLoad() { 
    super.viewDidLoad() 

    mapView.delegate = self 
} 

ref。我的MKMapView示例代码 https://github.com/koogawa/MKMapViewSample

+0

你能看看我的文章。它的类似http://stackoverflow.com/questions/33131213/regiondidchange-called-several-times-on-app-load-swift – RubberDucky4444

0

在我的代码中,我有一个非常类似于上述答案的答案,但是我添加了一个self。首先它看起来像这样

self.mapView.delegate = self