iphone - Hide the annotation view in map view

左心房为你撑大大i 提交于 2019-12-24 05:03:40

问题


In my view, i've nav bar at the top and remaining view is filled with map view. My Map view has pins and on click of pin, it will show annotations also. In the top right nav bar i've a button and on click of it, i want to remove the annotation view that popped up. (what ever annotation view is there, i want to remove from the view). Can some one tell me how to do it.

The simple task we can do is to send some touch event to the map view which will hide it..... am i right. how to do it?


回答1:


To hide the callout all you need to do is deselect the selected annotation. You do that by using...

- (void)deselectAnnotation:(id < MKAnnotation >)annotation animated:(BOOL)animated

For example:

[mapView deselectAnnotation:[mapView.selectedAnnotations objectAtIndex:0] animated:YES];

assuming mapView is what you named your MKMapView instance.



来源:https://stackoverflow.com/questions/4896558/iphone-hide-the-annotation-view-in-map-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!