selectAnnotation方法的Mapview不适用于iOS7
我正在使用iPhone的应用程序,我需要在其中显示不同位置的POIs引脚。我需要在第一个POI上显示默认弹出的标注。我已经设法为iOS6做到这一点,但在iOS7中面临问题。我在下面写我的代码,它在iOS6上运行良好,但在iOS7上运行得不错。它没有显示任何错误,但是对于iOS7, ,我无法在默认情况下调出地图POI上的弹出窗口。selectAnnotation方法的Mapview不适用于iOS7
这里是我的代码部分:
DDAnnotation *annotation2 = [[DDAnnotation alloc] initWithCoordinate:coordinates addressDictionary:nil] ;
annotation2.title = [[arrPOIs objectAtIndex:0] objectForKey:@"Name"];
annotation2.subtitle = [[arrPOIs objectAtIndex:0] objectForKey:@"AmbassadorTagline"];
annotation2.dictionaryData = [arrPOIs objectAtIndex:0];
annotation2.strCountNumber = [NSString stringWithFormat:@"1"];
[mapView selectAnnotation:annotation2 animated:YES];
[annotation2 release];
annotation2 = nil;
请顾得上我,如果你有任何想法/建议。
我用ios7此代码,这是很好的
第一
#import <MapKit/MapKit.h>
然后在
viewDidLoad中
添加以下代码
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = someLocation;
annotationCoord.longitude = someLocation;
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = annotationCoord;
annotationPoint.title = @"YourTitle";
annotationPoint.subtitle = @"YourSubtitle";
[map addAnnotation:annotationPoint];
感谢阿卜杜拉,我找到了解决方案。我错过了在选择注释之前添加一行。即: [mapView addAnnotation:annotationPoint]; 令人惊讶的是它没有受到iOS6的影响。这个问题只出现在iOS7上。 – user2897266
我检查这个方法DDAnnotaion也用简单的MapView的下降注解它`工作的iOS 7 *可以在下列情况
1) Annotation is not visible on mapView.
2) Annotation is not yet created/added to mapView.
可能性所以请检查。或提供完整的代码,说明如何以及在哪里添加注释。
请查看讨论点here.了解更多信息。
感谢AJPatel为您的答案。在我的情况下,它是没有 - “2”受到影响。我错过了在选择前添加它。 – user2897266
是的,我知道。你有没有检查你的整个代码,出于这个原因,它适用于iOS 6。 – AJPatel
感谢所有。最后,我找到了我的问题的解决方案。
我错过了在选择注释之前添加一行,即: [mapView addAnnotation:annotationPoint];
奇怪的是它没有受到iOS6的影响。这个问题只出现在iOS7上。
是来自https://github.com/digdog/MapKitDragAndDrop的'DDAnnotation'吗?这已经有好几年没有更新过了。也许它与iOS 7 – oefe
不兼容,请显示正确的代码在mapView上添加注释的方式/位置。 – AJPatel