iOS5 中 MKAnnotation 未选中
我的应用程序在地图上放置一个图钉,然后使用动画选择它,以便用户有视觉线索并可以立即阅读标题/副标题。以下代码在 iOS4 和 iOS5 中都适用,但在 iOS5 中,除非我在 selectAnnotation 方法中将动画更改为“否”,否则不会自动选择注释。
有什么想法吗?
MapAnnotations *pushpin = [[MapAnnotations alloc] initWithCoordinate:coordinate];
pushpin.title = [selectedStation valueForKey:@"name"];
pushpin.subtitle = [selectedStation valueForKey:@"address"];
[stationMap addAnnotation:pushpin];
[stationMap selectAnnotation:pushpin animated:YES];
[pushpin release]; pushpin = nil;
My app places a pushpin on the map and then selects its using animation so the user has a visual clue and can immediately read the title/subtitle. The following code works in both iOS4 and iOS5, but in iOS5, the annotation doesn't get selected automatically unless I change the animation to NO in the selectAnnotation method.
Any ideas why?
MapAnnotations *pushpin = [[MapAnnotations alloc] initWithCoordinate:coordinate];
pushpin.title = [selectedStation valueForKey:@"name"];
pushpin.subtitle = [selectedStation valueForKey:@"address"];
[stationMap addAnnotation:pushpin];
[stationMap selectAnnotation:pushpin animated:YES];
[pushpin release]; pushpin = nil;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道为什么它之前会起作用,但动画可能需要创建并准备好注释视图,这在添加注释后不太可能立即进行。
您可以做的是将选择移动到 didAddAnnotationViews 委托方法,该方法应该适用于所有 iOS 版本:
Not sure why it would work before but the animation probably requires the annotation view to be created and ready which is unlikely immediately after adding the annotation.
What you can do is move the selection to the
didAddAnnotationViews
delegate method which should work on all iOS versions: