简体   繁体   中英

Touch event on an pin annotation on a MKMapView

i've been trying to display a view controller when I tap on a pin annotation of my map View: The first time I used a container view and change his position in order to "hide" it. Than, when I tap on an annotation I used the func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView){} to move the position of the view controller that I want to display to the center of my screen. Unfortunately I wasn't able to close the view controller because when I tried to use the function dismissViewController .... It dismiss all the view controllers of my app. So I trie to move the position of the view controller that I want to display a when the user touch the close button, it works only one time, if I tap on an other annotation, the view controller won't show up. I can't do with segue because the annotation aren't shown in the main.storyboard To resume, my question is: How can I display a second View Controller by touching an annotation on my map.

I tried the function performseguewithidentifier on following method:

func mapView(mapView: MKMapView, didSelectAnnotationView view:  MKAnnotationView){
    // do your things here
} 

and it worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM