没有平移手势的 UIScrollView 上的水平滚动 [英] Horizontal scroll on UIScrollView without pan gesture
本文介绍了没有平移手势的 UIScrollView 上的水平滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何才能在使用 UIScrollView 时不调用平移手势识别器选择器.
How can I make it so that when I use my UIScrollView the pan gesture recognizer selector is not called.
我希望能够在不调用平移手势选择器的情况下在滚动视图中滚动.
I want to be able to scroll in the scroll view without the pan gesture selector being called.
这是我的平移检测功能:
Here is my pan detected function:
- (void)panDetected:(UIPanGestureRecognizer *)panRecognizer
{
CGPoint translation = [panRecognizer translationInView:self.view];
CGPoint imageViewPosition = self.draggableImage.center;
imageViewPosition.x += translation.x;
imageViewPosition.y += translation.y;
self.draggableImage.center = imageViewPosition;
[panRecognizer setTranslation:CGPointZero inView:self.view];
}
我不希望在页面底部使用 UIScrollView 时调用它.
I do not want it to be called when I am using my UIScrollView at the bottom of the page.
推荐答案
您可以从滚动视图中移除手势识别器
you could remove the gesture recognizer from the scroll view
NSArray* gestureRecognizers = [scrollView gestureRecognizers];
for (UIGestureReconizer* recog in gestureRecognizers) {
if ( [recog isKindOfClass:[UIPanGestureRecognizer Class]] )
[recog removeTarget:scrollView.delegate action:@selector(scrollViewDidScroll:)];
}
我不明白为什么需要这样做,但就是这样.
I don't understand why this is needed to be done, but here it is.
这篇关于没有平移手势的 UIScrollView 上的水平滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文