didTapInfoWindowOfMarker多个按钮单击事件信息

时间:2015-03-17 12:27:05

标签: ios iphone

我在谷歌地图中显示一些地图点。当用户点击该地图点时。我将显示markerInfoWindow。在这个窗口中,我使用两个按钮。每当用户点击该按钮时。触发 didTapInfoWindowOfMarker 。但我无法确定哪一个被点击了。你可以帮我吗?我不想使用任何其他方法。 感谢

更新: - 这是infoWindow代码。

-(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;
}

这里我试图点击监听器,首先是按钮,另一个是在这个窗口的任何部分点击如textField等所以我的两个新视图将推送

1 个答案:

答案 0 :(得分:-2)

  • 将按钮更改为属性。
  • 给出按钮标签。
  • 从逻辑 通过识别发送者并确定它是否是> 1来确定。或者<另一个 按钮(你需要通过使它们属性或保持在内存中 实例变量)。
  • 加载自定义Xib,所有这些都可以使用0行代码。