想让didSelectAnnotationView接到电话有点沮丧.
我的情况:当选择索引中的某一项时,我的应用程序使用TabBar控制器从索引视图切换到地图视图(索引选项卡到地图选项卡)。让它在4.3下工作没有问题,但在5.0以下是一个有趣的问题。
如果我以前选择了MAP选项卡(如地图视图中加载的那样),则会弹出注释“冒泡”以显示所选的point...no问题。但是,如果在从索引列表中选择一个项之前没有选择MAP选项卡,它将加载MAP视图,但不会调用didSelectAnnotationView方法。
这只会在once...as中发生,一旦加载了地图视图,一切都会按预期进行响应。
同样,在4.3下,无论以前是否加载了地图视图,每次都会调用didSelectAnnotationView。
有什么想法吗?
至于我的编码,我在viewDidLoad方法下加载所有注释,viewWillAppear是这样的:
//Run through all annotations
for (id<MKAnnotation> annotation in mapView.annotations) {
//Check if that annotation is the selected one
if (annotation.coordinate.longitude == mylongitude) {
[[mapView viewForAnnotation:annotation] setHidden:FALSE];
[mapView selectAnnotation:annotation animated:YES];
}
}发布于 2012-05-30 17:13:23
(我的代表还不够高,还不能发表评论)
首先,验证您的注释是否在问题场景中找到--在IF语句中放置一个断点以确认.
其他说明:
如果要选择的注释是屏幕外的,则select方法不会产生任何效果(根据文档)。注释当然是可用的,但在本例中它可能不会有与其关联的视图。
。
https://stackoverflow.com/questions/8212986
复制相似问题