【问题标题】:iOS Google Maps add additional UIGesturerRecognizeriOS 谷歌地图添加额外的 UIGesturerecognizer
【发布时间】:2013-04-22 08:25:41
【问题描述】:

我刚开始使用适用于 iOS 的 Google Maps SDK,但遇到了一些问题。我正在尝试添加以下代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Google map code here...

    UITapGestureRecognizer *listTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(listClick:)];
    [self.listButton addGestureRecognizer:listTap];
}

- (void)listClick:(UITapGestureRecognizer *)recognizer {
    NSLog(@"List button pressed");
}

但它似乎没有在图像上注册点击事件。我已经连接了 IBOutlet,但似乎谷歌地图正在接受所有的手势。我可以开始平移,将鼠标(或手指)放在列表​​按钮上并滑动,地图只会响应它。

我正在使用适用于 iOS v1.2 的 Google Maps SDK(应该是当前版本),目标 iOS 版本是 5.1。任何想法都会有所帮助,因为这让我很生气。

【问题讨论】:

    标签: ios uigesturerecognizer google-maps-sdk-ios


    【解决方案1】:

    你一定是在开玩笑......所以这就是发生的事情。故事板已选中User Interaction Enabled,但显然这并不意味着蹲下。我将代码更改为:

    UITapGestureRecognizer *listTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(listClick:)];
    self.listButton.userInteractionEnabled = YES;
    [self.listButton addGestureRecognizer:listTap];
    

    那里的关键是设置self.listButton.userInteractionEnabled = YES;

    一切正常,我的 iOS 开发世界不再颠倒。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-19
      • 1970-01-01
      相关资源
      最近更新 更多