Wie ziehen Sie eine Anmerkung mit MKMapView gezogen wird? (iOS)

Ich habe einen UIViewController enthält eine MKMapView. Ich habe eine Anmerkung zu meiner aktuellen Position, indem Sie den folgenden code:

import UIKit
import MapKit
class LocationViewController: UIViewController , MKMapViewDelegate ,CLLocationManagerDelegate {
    @IBOutlet weak var mapView: MKMapView!
    var locationManager: CLLocationManager!
    let regionRadius: CLLocationDistance = 1000
    var token: dispatch_once_t = 0
    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.delegate = self
        locationManager = CLLocationManager()
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.requestWhenInUseAuthorization()
        locationManager.startUpdatingLocation()
    }

func centerMapOnLocation(location: CLLocation) {
    let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate,
        regionRadius * 2.0, regionRadius * 2.0)
    mapView.setRegion(coordinateRegion, animated: true)
}

func mapView(mapView: MKMapView, didUpdateUserLocation userLocation: MKUserLocation) {

    if ((userLocation.coordinate.latitude != 0.0) && (userLocation.coordinate.longitude != 0.0)) {
        dispatch_once(&token) {
            self.centerMapOnLocation(userLocation.location!)
            let annotation = MapPin(title: "This Location", locationName: "Test", discipline: "None", coordinate: userLocation.coordinate)
            mapView.addAnnotation(annotation)
        }
    }
}  

Möchte ich die Anmerkung verschieben Sie den Kartenausschnitt verschoben oder gezogen durch den Benutzer. Zum Beispiel meine aktuelle Position ist New Albany und, wenn ich ziehen Sie die Karte, nicht die Beschriftung ändert sich die Bühne schweben in der Luft, bis ich die Freigabe auf der Oberseite des Pontotoc, so die Anmerkung Punkte, in denen ich veröffentlicht. Ich wäre dankbar für jede trifft oder gute tutorials auf MapKit.

Wie ziehen Sie eine Anmerkung mit MKMapView gezogen wird? (iOS)

Wie ziehen Sie eine Anmerkung mit MKMapView gezogen wird? (iOS)

InformationsquelleAutor user2768374 | 2015-10-17
Schreibe einen Kommentar