2014-07-08 5 views
0

MapQuest에서 작업하고 있지만 문제가 아닌 것 같습니다.사용자 지정 MQAnnotationView 단추를 클릭 할 수 없습니다.

지도 (MapQuest 포함)와 맞춤 핀이 있습니다. 나는 핀을 가볍게 칠 수 있고 나의 주문 설명 선 (꼬리표 및 단추로 xib 파일)는 튀어 나오고 모두는 잘 작동하고있다. 유일한 문제는 사용자 정의 콜 아웃보기 (UIView)에서 버튼을 누를 수 없다는 것입니다. 여기

내 코드는 다음 calloutView에

- (void)mapView:(MQMapView *)mapView didSelectAnnotationView:(MQAnnotationView *)view { 
     callOutView *calloutView = (callOutView *)[[[NSBundle mainBundle] loadNibNamed:@"callOutView" owner:self options:nil] objectAtIndex:0]; 
    CGRect calloutViewFrame = calloutView.frame; 
    calloutViewFrame.origin = CGPointMake(-calloutViewFrame.size.width/2 + 15, -calloutViewFrame.size.height); 
    calloutView.frame = calloutViewFrame; 

    [calloutView.my_button addTarget:self action:@selector(button_pressed:) forControlEvents:UIControlEventTouchUpInside]; //here is something wrong, button_pressed is never called 

[view addSubview:calloutView]; 
} 

답변

0

설정 userInteractionEnabled = YES; :

-(MQAnnotationView*)mapView:(MQMapView *)aMapView viewForAnnotation:(id<MQAnnotation>)annotation { 

    static NSString* identifier = @"Pins"; 
    MQAnnotationView * annotationView = (MQAnnotationView *)[self->mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; 

    annotationView = [[MQAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
    annotationView.image = [UIImage imageNamed:@"marker_schuhe"]; 

    annotationView.enabled = YES; 
    annotationView.canShowCallout = NO; 

    return annotationView; 
} 

그리고 내 didSelectAnnotationView 방법에

?

calloutview

- 사용자의 코멘트 후 편집 작동하지

@selector 경우 추가 시도 (가 MKAnotationView를 차단하기 때문에)이처럼 UIButtonUIGesture :

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] 
      initWithTarget:self action:@selector(button_pressed:)]; 
     tap.numberOfTapsRequired = 1; 
     [calloutView.my_button addGestureRecognizer:tap]; 
+0

감사합니다 마이클하지만 너의 제안은 효과가 없었어. 설명 선보기와 버튼이 모두 표시되지만 버튼을 클릭 할 수 없습니다. 전체 calloutView를 탭하면지도가 확대됩니다. 여기에 주요 문제가 있습니까? –

+0

안녕 마이클, UIGesture가 작동하지 않았습니다. button.frame이 UIView 외부에있을 수 있습니까? http://s30.postimg.org/r73zxx7up/IMG_1566.png 오른쪽의 버튼 ">"은 클릭 할 수 없으며 그 이유를 알 수 없습니다. –

관련 문제