ios - not able to tap on MKPinAnnotationView Second Time -


i have created custom annotation using code.

    - (mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation     {         static nsstring *const annotatioviewreuseid = @"annotatioviewreuseid";        // mkannotationview          mkpinannotationview *annotationview = (mkpinannotationview *)[mapview dequeuereusableannotationviewwithidentifier:annotatioviewreuseid];          if (!annotationview) {             annotationview = [[mkpinannotationview alloc] initwithannotation:annotation reuseidentifier:annotatioviewreuseid];         }          if ([annotation iskindofclass:[fbannotationcluster class]]) {             fbannotationcluster *cluster = (fbannotationcluster *)annotation;             cluster.title = [nsstring stringwithformat:@"%lu", (unsigned long)cluster.annotations.count];              uiview *view = [[uiview alloc]init];             view.backgroundcolor = [uicolor colorwithred:33.0/255.0 green:191.0/255.0 blue:133.0/255.0 alpha:1.0];              uilabel *label = [[uilabel alloc]init];             label.text = cluster.title;             label.textalignment = nstextalignmentcenter;             label.textcolor = [uicolor whitecolor];             label.textalignment = nstextalignmentcenter;             uifont *font = [uifont fontwithname:@"avenir-medium" size:14.0];             label.font = font;              label.frame = cgrectmake(0, 0, [self widthofstring:label.text]+20, [self widthofstring:label.text]+20);              view.frame = cgrectmake(0, 0, label.frame.size.width, label.frame.size.width) ;              view.layer.cornerradius =  view.frame.size.height/2;             view.layer.bordercolor = [uicolor whitecolor].cgcolor;             view.layer.borderwidth = 2.0;              view.clipstobounds = true;              [view addsubview:label];              (uiview *view in [annotationview subviews])             {                 [view removefromsuperview];             }             [annotationview addsubview:view];              annotationview.enabled = yes;             annotationview.annotation = annotation;             annotationview.canshowcallout = yes;              annotationview.pintintcolor = [uicolor clearcolor];          } else {              annotationview.pintintcolor = [uicolor clearcolor];              annotationview.layer.bordercolor = [uicolor clearcolor].cgcolor;             annotationview.layer.borderwidth = 0.0;              fbannotation *a = (fbannotation*)annotation;              nslog(@"amount %f",a.amount);              uiimage *image = [uiimage imagenamed:@"icon-marker-select"];              uiimageview *imgview = [[uiimageview alloc]init];              nsnumberformatter *formatter = [[nsnumberformatter alloc] init];             formatter.numberstyle = nsnumberformatterdecimalstyle;             formatter.maximumfractiondigits = 2;              nsstring *result = [formatter stringfromnumber:[nsnumber numberwithdouble:a.amount]];              nsstring *strdata = [nsstring stringwithformat:@"%@%@",a.currency,result];             uifont *font = [uifont fontwithname:@"avenir-medium" size:14.0];              nsmutableparagraphstyle *paragraphstyle = [[nsparagraphstyle defaultparagraphstyle] mutablecopy];             paragraphstyle.alignment = nstextalignmentcenter;             nsdictionary *attributes = @{                                          nsfontattributename : font,                                          nsparagraphstyleattributename : paragraphstyle,                                          nsforegroundcolorattributename : [uicolor whitecolor]                                          };             cgsize textsize = [strdata sizewithattributes:attributes];              cgrect textrect = cgrectmake(5, (image.size.height-textsize.height)/2 - 2, textsize.width , textsize.height);              uilabel *textlable = [[uilabel alloc]initwithframe:textrect];              textlable.textcolor = [uicolor whitecolor];             textlable.font = font;             textlable.text = strdata;              uiimage *lightsymimg = [uiimage imagenamed:@"icon_lightning"];             uiimageview *lightimage = [[uiimageview alloc]init];              lightimage.image = lightsymimg;              cgrect imgrect = cgrectmake(textrect.origin.x+textrect.size.width, (image.size.height-lightsymimg.size.height)/2 - 2, lightsymimg.size.width,lightsymimg.size.height);              lightimage.frame = imgrect;              imgview.frame = cgrectmake(0, 0, imgrect.size.width + imgrect.origin.x+5, image.size.height);              imgview.image = image;              (uiview *view in [annotationview subviews])             {                 [view removefromsuperview];             }             annotationview.annotation = annotation;              [annotationview addsubview:imgview];             [annotationview addsubview:textlable];             [annotationview addsubview:lightimage];              annotationview.enabled = yes;             annotationview.canshowcallout = no;         }         return annotationview;         } 

and in didselect method have written code present view controller

 - (void)mapview:(mkmapview *)mapview didselectannotationview:(mkannotationview *)view     {         nslog(@"didselectannotationview");          if ([view.annotation iskindofclass:[fbannotationcluster class]]) {              nslog(@"fbannotationcluster select annotation");         }         else{               spotdetailvc *locdetailvc = [[uistoryboard storyboardwithname:@"spotdetail" bundle:nil] instantiateviewcontrollerwithidentifier:@"spotdetailvc"];              [self presentviewcontroller:navcontroller animated:yes completion:nil];         }     } 

now when click on annotation first time works after dismiss view again click on same annotation not works.

please help, know it's silly mistake not able configure out one.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -