0

私は、位置座標やその他のカスタム注釈に基づいて現在の位置を表示する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; 
}
4

1 に答える 1

0

これを解決しました。これは、[location manager stopUpdatingLocation]が正しく機能していないためにピンが何度も再描画されるために発生します。したがって、bool変数を使用して、Mapviewを初期化するクラスの呼び出しを何度も停止します。

@aBitObvious:サポートありがとうございます...

于 2011-01-20T08:54:32.960 に答える