tnishanth
tnishanth

Reputation: 11

Touchbegan method not called

touchesBegan methods not called on GMSmapview.I was expecting this method to be called on touching or dragging map .can someone let me know whats wrong with this code

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setUserInteractionEnabled:YES];
    _mapview.userInteractionEnabled=YES;
    _mapview.settings.consumesGesturesInView = false;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches
           withEvent:(UIEvent *)event{

    NSLog(@"touchbegan started"); 
}

- (void)touchesMoved:(NSSet<UITouch *> *)touches
           withEvent:(UIEvent *)event{
    NSLog(@"touchesMoved started");
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches
           withEvent:(UIEvent *)event{
    NSLog(@"touchesEnded started");
}

Upvotes: 0

Views: 329

Answers (1)

Sid Mhatre
Sid Mhatre

Reputation: 3417

You can also refer GMSMapViewDelegate Protocol Reference

To detect if the user dragged the map I think it's better to use this method

- (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture

and check if gesture argument is true.

- (void) mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position 

The didChangeCameraPosition is called, as mentioned, many times but since it's also called by both setting the map center from code and as a result of a gesture you can't really see the difference in that method alone.

- (void) mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *)position 

Called before the camera on the map changes, either due to a gesture, animation (e.g., by a user tapping on the "My Location" button) or by being updated explicitly via the camera or a zero-length animation on layer.

Upvotes: 1

Related Questions