我所拥有的是具有多个子视图的视图控制器视图。层次结构类似于:
[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
想要一些指导。
更新
快速清理和构建,现在它正在工作!