0
주석을 UITapGestureRecognizer로 연결합니다. 나는 터치를 감지하고 싶다.보낸 사람을 통해 특수 효과에 대한 참조를 얻는 방법은 무엇입니까?
if ([annotation isKindOfClass:[Annotation class]])
{
NSString * annotationIdentifier = @"UserAnnotationIdentifier";
CustomAnnotationView * customAnnotationView = (CustomAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!customAnnotationView)
{
customAnnotationView = [[CustomAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
UITapGestureRecognizer *tapGesture =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(calloutTapped:)];
[customAnnotationView addGestureRecognizer:tapGesture];
나는 코드의 바닥을 사용하지만, 그것은
-(void) calloutTapped:(id) sender {
id<MKAnnotation> annotation = ((MKAnnotationView*)sender.view).annotation;
ERROR 컴파일에서 오류가 발생 : 속성보기는 유형 __strong ID의 객체를 찾을 수 없습니다
덕분에, 당신은 내 일 만들기! 잠시 후 대답을 수락합니다. – user3300062
보낸 사람을 UITapGestureRecognizer로 캐스팅하려면 어떻게해야합니까? 보낸 사람 = (UITapGestureRecognizer *) 보낸 사람; 작동하지 않음 – user3300062
각 항목의 전송에 대한 내 답변이 업데이트되었습니다. 주석 뷰의 'tag'속성을 설정하여 식별 할 수 있고 여러 탭 동작에 대해이 메소드를 재사용 할 수 있습니다. 그냥 생각. – graver