到目前为止我所做的是创建一张地图.然后显示用户位置并居中,以便地图在旅行时居中(汽车等)
但是现在我想添加一个长按手势,这样如果用户输入一个引脚就会被丢弃.我一直在努力学习教程和模拟器崩溃.
我如何添加,longPressGesturerecognizer以便它在我的上面放一个别针mapView.
这是我的代码 -
import UIKit
import MapKit
import CoreLocation
class Page2: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate{
@IBOutlet var mapView: MKMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
//blue dot on the map
self.mapView.showsUserLocation = true
//tracking mode on
self.mapView.userTrackingMode = .follow
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// location Manager Delegate center user on map
private …Run Code Online (Sandbox Code Playgroud)