2011-11-17 2 views
2

콜 아웃 버블이있는 핀을 표시하기 위해 MKMapView를 얻으려고합니다. 핀을 표시 할 수 있지만 콜 아웃을 표시하는 방법을 파악할 수 없습니다.MKAnnotationView가 콜 아웃을 표시하지 않습니다.

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation { 
    if (annotation == mapView.userLocation) { 
     return nil; 
    } 
    MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"]; 
    pinView.pinColor = MKPinAnnotationColorGreen; 
    [pinView setCanShowCallout:YES]; 
    pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    pinView.animatesDrop = YES; 
    [self performSelector:@selector(displayPinCallOutView) withObject:nil afterDelay:0.3]; 
    return pinView; 
} 

답변

5

당신이 즉시 주석이지도에 추가로 표시 할 선을 얻으려고 노력하는 경우, 당신은 didAddAnnotationViews 대리자 메서드에서 할 필요가 :

내 코드가

-(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views 
{ 
    //Get reference to annotation you want to select... 
    //You could search through mapView.annotations array 
    //or keep ivar reference to it. 
    id<MKAnnotation> annToSelect = ... 

    [mapView selectAnnotation:annToSelect animated:YES]; 
} 

viewForAnnotation 방법에서 제거하십시오.

+0

작동하지 않습니다. (그러나 핀을 선택하고 콜 아웃을 표시 할 수 없습니다. –

+0

didAddAnnotationViews 메소드가 호출 되었습니까? (NSLog를 입력하십시오)? annToSelect를 설정하는 방법을 보여줍니다. "핀을 선택할 수없고 설명 선을 표시 할 수 없습니다." – Anna

+0

예, 핀을 탭하면 설명 선이 표시되지 않습니다. –

관련 문제