iOS 4 -MKMAPカスタムアノテーションの問題を配置します
-
12-10-2019 - |
質問
私は、位置座標やその他のカスタムアノテーションに基づいて現在の場所を示すMKMAPビューに取り組んでいます。 iPhone 3GSには正しく表示されますが、iPhone 4.0以上では、毎回カスタムアノテーションを表示しません(ランダムに緑色のピンのみが他のピンではないことを示しています)。何が問題になるのでしょうか? iOS 4.0以上に問題はありますか?もしそうなら、どうすればそれを解決できますか。誰でも私を助けることができますか
ありがとう
ViewForAnnotationメソッドからのコード...
if ([annotation isMemberOfClass:[MKUserLocation class]])
{
return nil;
}
if (annotation==self.normalAnnotation)
{
NSLog(@"green pin");
MKPinAnnotationView *annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"NormalAnnotation"] autorelease];
annotationView.canShowCallout = NO;
annotationView.pinColor = MKPinAnnotationColorGreen;
return annotationView;
}
else
{
NSLog(@"Custom pin");
Marker *obj = [database getMarkerWithName:[annotation title]];
MKAnnotationView *newAnnotation=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"]autorelease];
newAnnotation.image = [UIImage imageNamed:obj.markerImage];
newAnnotation.canShowCallout=YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[button addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[button setTag:obj.markerID];
newAnnotation.rightCalloutAccessoryView=button;
//annotation.annotationObj = newAnnotation;
return newAnnotation;
}
解決
ロケーションマネージャーStopUpDatingLocation]が適切に機能していないため、ピンが何度も再描画しているため、これを解決しました。Bool変数では、MapViewを何度も初期化するクラスを呼び出すために停止します。
@Abitobvious:サポートありがとうございます...
所属していません StackOverflow