[英]selectAnnotation method of Mapview calling deselect method also iOS
[英]selectAnnotation method of Mapview doesn't work for iOS7
我正在使用iPhone的應用程序,我需要在其中顯示不同位置的POI引腳。 我需要在第一個POI上顯示默認彈出的callout。 我已經設法為iOS6做到了這一點,但在iOS7中面臨問題。 我正在編寫下面的代碼,它適用於iOS6但不適用於iOS7。 它沒有顯示任何錯誤,但對於iOS7,默認情況下我無法在地圖POI上調出彈出窗口。
這是我的代碼部分:
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上。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.