在同时实现捏合和双触摸平移手势时遇到问题

时间:2012-11-21 23:56:18

标签: ios cocoa-touch

我所拥有的是具有多个子视图的视图控制器视图。层次结构类似于:

[view controller view]
    [container view]
        [view1,view2,view3,view4,view5,etc...]
            [gesture view (full screen)]

我试图实施捏合和双指平移,但无法让它们同时工作:

UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]
                                 initWithTarget:self action:@selector(handlePinch:)];
pinch.delegate = self;

UIPanGestureRecognizer *pullDownContainerView = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pullingDownContainerView:)];
pullDownContainerView.minimumNumberOfTouches = 2;
pullDownContainerView.maximumNumberOfTouches = 2;
pullDownContainerView.delegate = self;

[self.touchView addGestureRecognizer:pullingDownContainerView];
[self.touchView addGestureRecognizer:pinch];

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}

另一个奇怪的事情是shouldRecognizeSimultaneouslyWithGestureRecognizer没有被调用(我已经实现了UIGestureRecognizerDelegate协议)。 他们确实单独工作。我已经阅读了一些关于使用滚动视图的内容,其中可以使用平移和捏合等等。因此,我需要使用UIView

替换容器视图UIScrollView

想要一些指导。

更新

快速清理和构建,现在它正在工作!

0 个答案:

没有答案