-1

I am displaying some map points in google map. when user will click on that map point. I markerInfoWindow will be display. In this window, I am using two buttons. whenever user will click on that buttons. didTapInfoWindowOfMarker fires. but i amn't able to identify that which one has been clicked. may you please help me for that? i don't want to use any other approach. Thanks

update:- This is infoWindow code.

-(void)prepareBubble
{
//  UIView *bubble = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 80)];
self .frame = CGRectMake(0, 0, 260, 130);
self.backgroundColor = [UIColor clearColor];
//  self.layer.borderColor = [UIColor grayColor].CGColor;
//  self.layer.borderWidth = 1;
//  self.layer.cornerRadius = 7;

UIImageView *bg = [[UIImageView alloc] initWithFrame:self.frame];
bg.image = [UIImage imageNamed:@"popup.png"];
[self addSubview:bg];

self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 5, 150, 40)];
self.titleLabel.backgroundColor = [UIColor clearColor];
[self.titleLabel setAdjustsFontSizeToFitWidth:TRUE];
self.titleLabel.numberOfLines = 0;
self.titleLabel.font = [UIFont fontWithName:FontNameArialBold size:14];
self.titleLabel.text = _title;

self.addressLabel= [[UILabel alloc] initWithFrame:CGRectMake(90, 40, 150, 35)];
self.addressLabel.backgroundColor = [UIColor clearColor];
[self.addressLabel setAdjustsFontSizeToFitWidth:TRUE];
self.addressLabel.numberOfLines = 0;
self.addressLabel.font = [UIFont fontWithName:FontNameArial size:12];
self.addressLabel.text = _address;

self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 70, 70)];
[self addSubview:self.imageView];
self.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_imageUrl]]];
if ( self.imageView.image == nil )
{
    self.imageView.image = [UIImage imageNamed:DefaultImage100];
}
//  [[[CustomNetwork alloc] init] setImage:_imageUrl onImageView:self.imageView withPlaceHolderImage:DefaultImage100];

[self addSubview:self.titleLabel];
[self addSubview:self.addressLabel];
if ( _ratings > 0 )
{
    [self addSubview:[self addStar:_ratings]];
}

if( _hasTeeTimes ) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Book" forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
UIImage *buttonImage = [UIImage imageNamed:@"button_orange_large.png"];
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
button.frame = CGRectMake(200, 75, 45, 25);
[self addSubview:button];
}
//  return self;
}

here I am trying to make to click listener, first is on button and another is on tap in any part of this window like as textField etc. so my two new view will push

Rahul Rawat
  • 999
  • 2
  • 17
  • 40
  • Any chance you can show some of the code you are using? - specifically around setting up the buttons? - also are you writing your app in swift or ObjC? – Wez Mar 24 '15 at 13:39
  • @Wezly, I am writing to app in Objective C. – Rahul Rawat Mar 24 '15 at 14:07
  • See http://stackoverflow.com/questions/15213049/add-buttons-to-view-returned-by-markerinfowindow-delegate-method –  Mar 24 '15 at 15:12

1 Answers1

-2
  • Change the buttons to properties.
  • Give the buttons tags.
  • Logically determine by identifying the sender and see if it is > or < the other button (which you need to keep in memory by making them properties or instance variables).
  • load custom Xibs, and all of these will work with 0 lines of code.
Stephen J
  • 2,367
  • 2
  • 25
  • 31
  • I gave the steps needed to identify which button is which, and suggested using custom Nibs instead. I'm using tags because the OP requested to not use any other approach, but I highly suggest using another approach because visuals should all be in the Xib instead, and it would improve his workflow. So anyone downvoting, realize I stay within the constraints of the question. – Stephen J Aug 25 '17 at 20:33