IOS MKMapView事件监听

1 class ViewController:UIViewController,MKMapViewDelegate
2 override func viewDidLoad() {
3 super.viewDidLoad()
4 // Do any additional setup after loading the view,
typically from a nib.
5
6 let mapView = MKMapView(frame:self.view.bounds)
7 mapView.delegate = self
8 mapView.mapType = MKMapType.standard
9
10 let coordinate2D = CLLocationCoordinate2D(latitude:
39.915352, longitude:116.397105)
11 let region = MKCoordinateRegionMake(coordinate2D,
MKCoordinateSpanMake(0.02, 0.02))
12 mapView.setRegion(region, animated:true)
13
14 self.view.addSubview(mapView)
15 }
16 func mapView(_ mapView:MKMapView,
regionWillChangeAnimated animated:Bool) {
17 print(“当前方法为:regionWillChange”)
18 }
19
20 func mapView(_ mapView:MKMapView,
regionDidChangeAnimated animated:Bool) {
21 print(“当前方法为:regionDidChange”)
22 }
23
24 func mapViewWillStartLoadingMap(_ mapView:
MKMapView) {
25 print(“当前方法为:mapViewWillStartLoadingMap”)
26 }
27
28 func mapViewWillStartRenderingMap(_ mapView:
MKMapView) {
29 print(“当前方法为:mapViewWillStartRenderingMap”)
30 }
31
32 func mapViewDidFinishLoadingMap(_ mapView:
MKMapView) {
33 print(“当前方法为:mapViewDidFinishLoadingMap”)
34 }
35
36 func mapViewDidFinishRenderingMap(_ mapView:
MKMapView, fullyRendered:Bool) {
37 print(“当前方法为:mapViewDidFinishRenderingMap”)
38 }

//还可以给地图添加注释

你可能感兴趣的:(IOS MKMapView事件监听)