【问题标题】:How to pinch google map when it set in UIScrollView in iOS Objective C在iOS Objective C的UIScrollView中设置时如何捏谷歌地图
【发布时间】:2016-12-15 10:21:03
【问题描述】:

我在 UIScrollView 的视图中设置了 Google Map。一切正常,但我无法我的地图。如何解决?

【问题讨论】:

    标签: ios objective-c xcode google-maps uiscrollview


    【解决方案1】:

    Salaam Reza jaan.

    在你的情况下,你可以使用这样的东西。干杯。

    编辑:这是一种更好的方法。 Behbakht shid, direh inja :P

    - (void) scaleSelfWith:(UIPinchGestureRecognizer *)gestureRecognizer{
    if ([gestureRecognizer numberOfTouches] >1) {
    
        //getting width and height between gestureCenter and one of my finger
        float x = [gestureRecognizer locationInView:self].x - [gestureRecognizer locationOfTouch:1 inView:self].x;
        if (x<0) {
            x *= -1;
        }
        float y = [gestureRecognizer locationInView:self].y - [gestureRecognizer locationOfTouch:1 inView:self].y;
        if (y<0) {
            y *= -1;
        }
    
        //set Border
        if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
            xDis = self.bounds.size.width - x*2;
            yDis = self.bounds.size.height - y*2;
        }
    
        //double size cause x and y is just the way from the middle to my finger
        float width = x*2+xDis;
        if (width < 1) {
            width = 1;
        }
        float height = y*2+yDis;
        if (height < 1) {
            height = 1;
        }
        self.bounds = CGRectMake(self.bounds.origin.x , self.bounds.origin.y , width, height);
        [gestureRecognizer setScale:1];
        [[self layer] setBorderWidth:2.f];
    }
    } 
    

    【讨论】:

    • 首先我必须在 mapView 上添加手势?
    • 手势添加到 UIScrollView 但不能添加到 self.mView(我的地图视图)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-05
    • 1970-01-01
    相关资源
    最近更新 更多