iOS谷歌地图SDK - 捏合手势缩放效果,无需滚动和更改位置

时间:2015-03-04 17:57:56

标签: ios objective-c google-maps-sdk-ios

我想在不更改相机目标的情况下在GMSMapView中进行捏合手势。所以我添加了一个UIPinchGestureRecognizer来阻止GMSUISettings中的scrollGestures。

- (void)zoomGestureHandler:(UIPinchGestureRecognizer *)recognizer
{
    if([recognizer state] == UIGestureRecognizerStatePossible)
    {

    }
    else if([recognizer state] == UIGestureRecognizerStateBegan)
    {
        NSLog(@"PINCH BEGAN\n");
        _mapView.settings.scrollGestures = NO;
    }
    else if([recognizer state] == UIGestureRecognizerStateChanged)
    {

    }
    else if([recognizer state] == UIGestureRecognizerStateEnded)
    {
        NSLog(@"PINCH END\n");
        _mapView.settings.scrollGestures = YES;
    }
    else if([recognizer state] == UIGestureRecognizerStateCancelled)
    {

    }
    else if([recognizer state] == UIGestureRecognizerStateFailed)
    {

    }
    else
    {

    }
}

当慢速捏动手势完成时,它正在工作。如果用户进行快速捏合手势,相机会在缩放动画后跳开。有没有人知道如何通过可靠的解决方案实现我的目标?谢谢!

1 个答案:

答案 0 :(得分:2)

在针对该问题与谷歌的错误中心联系后,他们通过更新修复了它。

获取谷歌地图sdk:1.10.0或更高版本。

解决方案是在配置GMSMapview时简单地添加此行:

_mapView.settings.allowScrollGesturesDuringRotateOrZoom = NO;