How to detect when MKUserTrackingBarButtonItem is used

為{幸葍}努か 提交于 2019-12-06 03:02:37

问题


I'm currently trying to find a way to detect when the MKUserTrackingBarButtonItem is used, other than deal with the mapView:didUpdateUserLocation: delegate method.

I tried to setAction of the MKUserTrackingBarButtonItem to call my function (check this thread), but of curse it removes the updating location action, which I don't want.

I don't find any delegate method triggered :/

Thanks for any idea.


回答1:


If your MKUserTrackingBarButtonItem has been assigned a MKMapView to operate on then the map view's delegate will receive mapView:didChangeUserTrackingMode:animated: when the tracking mode is changed (which is done by pressing that button).

ref: http://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html#//apple_ref/occ/intfm/MKMapViewDelegate/mapView:didChangeUserTrackingMode:animated:



来源:https://stackoverflow.com/questions/16830861/how-to-detect-when-mkusertrackingbarbuttonitem-is-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!