MKMapView,触摸pinview时如何添加自定义视图?
MKMapView 默认情况下,点击 pin 视图会出现带有标题和副标题的小黑框,但现在我想在视图上显示更多的数据。我想在单击图钉视图时显示客户视图。
有人做过类似的事情吗?我尝试过以下方法,但都不起作用:
- 使用代理访问mapView的点击事件:didSelectAnnotationView,但以上委托只支持ios4.x
- 使用tapgesture捕获事件,仅ios3.2之后支持
- 尝试继承MKMapView,发现无法获取触摸事件。
MKMapView default, click on the pin view will appear with the title and subtitle of a small black box, but now I want to display the data more on a view. I want to display a customer view when I click on a pin view.
Has anyone done something similar? I have tried the following methods, but they did not work:
- using a proxy access to the click event mapView: didSelectAnnotationView, but more than the delegate only supports ios4.x
- use tapgesture to capture the event, only support after ios3.2
- try to inherit MKMapView, found it impossible to get touch events.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也可能重复 带有自定义 MKAnnotation 的 MKMapView
以下是创建自定义标注的方法
http://blog.asolutions.com /2010/09/building-custom-map-annotation-callouts-part-1/
想知道如何解决
“3.尝试继承MKMapView,发现无法获取触摸事件。”在早于iOS4.x的设备上,这里是如何
.h文件
.m文件
-(MKAnnotationView *)mapView :(MKMapView )mapViewParam viewForAnnotation:(id )annotation {
静态 NSString PIN_RECYCLE_ID = @"pin";
....
also possible duplicate of MKMapView with custom MKAnnotation
Here is how you can create a custom callout
http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-1/
Wondering how to solve
"3. try to inherit MKMapView, found it impossible to get touch events." on earlier than iOS4.x devices, here is how
.h file
.m file
-(MKAnnotationView *)mapView:(MKMapView )mapViewParam viewForAnnotation:(id )annotation {
static NSString PIN_RECYCLE_ID = @"pin";
....