我所拥有的是带有几个子视图的视图控制器视图。层次结构类似于:
[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
想要一些指导。
更新:
进行了快速清洁和构建,现在可以正常工作了!