使用手势识别器时,表格视图不会滚动 [英] Table view doesn't scroll when I use gesture recognizer
问题描述
我的应用程序有一个表格视图(当然还有滚动),这个视图使用手势识别器(就像在Facebook应用程序上一样)打开和关闭。
My app has a table view (with a scroll-into of course) and this view slides on and off with a gesture recognizer (like on the Facebook app).
如果我使用按钮将[表格视图滑动到屏幕],它可以正常工作,但是当我使用手势识别器时,表格视图不能再滚动。
If I use a button to slide [the table view onto the screen], it works fine but when I use a gesture recognizer, the table view can't be scrolled anymore.
以下是带有问题的手势识别器代码:
Here is the code of gesture recognizer with the problem:
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
有人有想法吗?
推荐答案
您的手势可能会阻止滚动视图手势的工作,因为默认情况下,一次只能识别1个手势。尝试添加自己作为手势和实施的代表:
Your gesture is probably preventing the scroll view gesture from working because by default only 1 gesture can be recognising at a time. Try adding yourself as the delegate of your gesture and implementing:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
self.slidingViewController.panGesture.delegate = self;
另外,添加< UIGestureRecognizerDelegate>
到您实施的协议列表
also, add <UIGestureRecognizerDelegate>
to the list of protocols you implement
这篇关于使用手势识别器时,表格视图不会滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!