themanatuf
themanatuf

Reputation: 3130

iOS Google Maps add additional UIGesturerRecognizer

I just started using the Google Maps SDK for iOS and I'm having a bit of a problem. I'm trying to add the following code:

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

But it doesn't seem to register the tap event on the image. I've hooked up the IBOutlet, but it seems the Google Map is taking ALL of the gestures. I can start panning put putting my mouse (or finger) on the list button and swipe and the map ONLY will respond to it.

I'm using Google Maps SDK for iOS v1.2 (which should be the current version) and target iOS version is 5.1. Any thoughts would be helpful as this has been driving me batty.

enter image description here

Upvotes: 1

Views: 1507

Answers (1)

themanatuf
themanatuf

Reputation: 3130

You've gotta be kidding... So here's what happened. The Storyboard has User Interaction Enabled checked, but apparently that doesn't mean squat. I changed my code to:

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

The key there was setting self.listButton.userInteractionEnabled = YES;

Everything works as expected and my world of iOS development is no longer upside down.

Upvotes: 1

Related Questions