ios - UITapGestureRecognizer on a subview of MKAnnotationView not working -


i trying add tap recognizer show additional information callout. tried calling selector "showpersoninfo" directly , it's working. but, when try add in uitapgesturerecognizer on subview of mkannotationview working on. selector not firing when tap.

this code inside .m of subclass of mkannotationview

- (void)layoutsubviews {      [self addsubview:self.imagecontainerview];      uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(showpersoninfo:)];     [self.imagecontainerview addgesturerecognizer:tap];  }  - (void)showpersoninfo:(uitapgesturerecognizer *)tap {      nslog(@"annotation imageview touched");     [self addsubview:self.personinfoview];  } 

you can use mapview delegate method adding actions annotation view

 - (mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id <mkannotation>)annotation     {         if (annotation == mapview.userlocation)             return nil;          static nsstring *s = @"identifier";         mkannotationview *pin = [mapview dequeuereusableannotationviewwithidentifier:s];         if (!pin) {             pin = [[mkpinannotationview alloc]initwithannotation:annotation reuseidentifier:s];             pin.canshowcallout = yes;             pin.image = [uiimage imagenamed:@"pin.png"];             pin.calloutoffset = cgpointmake(0, 0);             uibutton *button = [uibutton buttonwithtype:uibuttontypedetaildisclosure];             [button addtarget:self                        action:@selector(showpersoninfo:) forcontrolevents:uicontroleventtouchupinside];             pin.rightcalloutaccessoryview = button;         }         return pin;     } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -