MapKit iOS 9 detailCalloutAccessoryView usage

后端 未结 4 1030
遥遥无期
遥遥无期 2020-12-05 05:39

After watching WWDC video 206 I assumed this would be a trivial task of adding the detail callout view to a mapView annotation view.

So, I assume Im doing something

4条回答
  •  一生所求
    2020-12-05 06:04

    1. Create a UIView and add it to yours maps VC in the Storyboard

    Here you can set the size, constraints, add buttons, images, etc - layout how you want. Stack views work perfect in this instance.

    2. Create and outlet to your Maps VC

    Control drag as per usual, from your custom view.

    @IBOutlet var customDetailView: UIView!
    

    3. Set the detailCalloutAccessoryView for your pin

    For example

    func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView) {
        view.detailCalloutAccessoryView = customDetailView
    }
    

    Success

提交回复
热议问题