خرید بک لینک

Vote count: 0

here is my code. I have tried all the solutions available but I am not able to put image I wish to instead of the default aotation red pin in my code. any help is appreciated. thank you

import MapKit

class ViewController: UIViewController, MKMapViewDelegate {

@IBOutlet var map: MKMapView!

override func viewDidLoad() {
    super.viewDidLoad()

    var location = CLLocationCoordinate2DMake(18.956449, 72.810597)

    var span = MKCoordinateSpanMake(0.009, 0.009)
    var region = MKCoordinateRegion(center: location, span: span)

    map.setRegion(region, animated: true)

    var aotation = MKPointAotation()
    aotation.coordinate = location
    aotation.title = "Wilson College"
    aotation.subtitle = "Commerce College"

    map.addAotation(aotation)
    print("showing on map")

    mapView(map, viewForAotation: aotation)


}



func mapView(mapView: MKMapView, viewForAotation aotation: MKAotation) -> MKAotationView? {

    let identifier = "MyPin"
    print("inside viewForAotation")
    if aotation.isKindOfClass(MKUserLocation) {
        retu nil
    }

    let detailButton: UIButton = UIButton(type: UIButtonType.DetailDisclosure)

    // Reuse the aotation if possible
    var aotationView = mapView.dequeueReusableAotationViewWithIdentifier(identifier)

    if aotationView == nil
    {
        aotationView = MKAotationView(aotation: aotation, reuseIdentifier: "pin")
        aotationView!.canShowCallout = true
        aotationView!.image = UIImage(named: "VRtest.png")
        aotationView!.rightCalloutAccessoryView = detailButton
        print("editing aotation")
    }
    else
    {
        aotationView!.aotation = aotation
    }

    retu aotationView
}

enter image description here

asked 4 mins ago

1 Answer

Vote count: 0

Try this

 aotationView = MKAotationView(aotation: aotation, reuseIdentifier: "pin")
aotationView!.canShowCallout = true
aotationView!.image = UIImage(named: "custom_pin.png")
aotationView!.rightCalloutAccessoryView = detailButton

answered 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 10 ارديبهشت 1395 ساعت: 19:27

صفحه بندی