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 called addresslabel
  • uibutton called button

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), call showinfowindow(). 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:

similar question 1
similar question 2


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -