手势识别器和 TableView [英] Gesture Recognizers and TableView
本文介绍了手势识别器和 TableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个涵盖所有 UITableView 的 UIView.UIView 使用手势识别器来控制表格显示的内容.我仍然需要垂直 UITableView 滚动和行点击.我如何将这些从手势识别器传递到桌子上?
I have a UIView which covers all of a UITableView. The UIView is using gesture recognizers for control of what the table displays. I still need the vertical UITableView scrolling and row taps. How do I pass these on to the table from the gesture recognizers?
推荐答案
将你的手势分配给 table view,table 会处理它:
Assign your gesture to the table view and the table will take care of it:
UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSwipeFrom:)];
[gesture setDirection:
(UISwipeGestureRecognizerDirectionLeft
|UISwipeGestureRecognizerDirectionRight)];
[tableView addGestureRecognizer:gesture];
[gesture release];
然后在您的手势操作方法中,根据方向进行操作:
Then in your gesture action method, act based on the direction:
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
[self moveLeftColumnButtonPressed:nil];
}
else if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
[self moveRightColumnButtonPressed:nil];
}
}
表格只会在内部处理完您要求的手势后才会传递给您.
The table will only pass you the gestures you have asked for after handling them internally.
这篇关于手势识别器和 TableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文