2011-01-19 61 views
0

我正在MKMap視圖顯示當前位置基於位置座標和其他自定義註釋。它在Iphone 3gs上正確顯示,但在iPhone 4.0或更高版本上,它不會每次都顯示自定義註釋(隨機顯示的只是綠色別針而非其他)。可能是什麼問題? ios 4.0及以上版本有問題嗎?如果是這樣,我們如何解決它。可有人幫我Ios 4 - Mkmap放置自定義註釋問題

感謝

代碼從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; 
} 
+0

顯示您的viewForAnnotation方法的代碼。 – Anna 2011-01-19 12:02:05

回答

0

我解決了這個,這是因爲該引腳,因爲一次又一次地重繪[位置管理器stopUpdatingLocation]工作不正常.so與bool變量我停止調用一次又一次初始化Mapview的類。

@aBitObvious:非常感謝您的支持,謝謝...