objective c - Button on Custom info Window not Receiving Action in ios -
i using google maps in ios application , have implemented custom info window showing title of marker.
now, added button on custom info window problem button action method not called.
custominfowindow.h
#import <uikit/uikit.h> @interface custominfowindow : uiview @property (nonatomic,weak) iboutlet uilabel *addresslabel; @property(nonatomic) iboutlet uibutton *button; @end
and in infowindow.xib
, have added
uilabel
calledaddresslabel
uibutton
calledbutton
viewcontroller.h
#import "custominfowindow.h" @interface viewcontroller : uiviewcontroller<gmsmapviewdelegate> { gmsmapview *mapview; } @end
viewcontroller.m
- (uiview *)mapview:(gmsmapview *)mapview markerinfowindow:(gmsmarker *)marker { nslog(@"mrker tapped"); custominfowindow *infowindow = [[[nsbundle mainbundle]loadnibnamed:@"infowindow" owner:self options:nil] objectatindex:0]; infowindow.addresslabel.text = marker.title; [infowindow.button addtarget:self action:@selector(buttonpressed) forcontrolevents:uicontroleventtouchupinside]; return infowindow; } -(void)buttonpressed { nslog(@"button pressed"); }
basically... buttonpressed
method not fire.
i haven't used google maps sdk after following few links, seems you're trying accomplish may not easy.
ref: https://developers.google.com/maps/documentation/android/infowindows
ps: maybe android documentation seems holds true ios well.
to quote:
note: info window drawn not live view. view rendered image (using
view.draw(canvas)
) @ time returned. means subsequent changes view not reflected info window on map. update info window later (for example, after image has loaded), callshowinfowindow()
. furthermore, info window not respect of interactivity typical normal view such touch or gesture events. can listen generic click event on whole info window described in section below.
you instead implement gmsmapviewdelegate's -didtapinfowindowofmarker:
delegate method check if infowindow tapped.
(the drawback entire infowindow becomes 1 button)
other links:
Comments
Post a Comment