两个手指UISwipeGestureRecognizer与UITableView

时间:2013-04-20 23:41:55

标签: ios uitableview uigesturerecognizer uiswipegesturerecognizer

我正在寻找向UITableView添加一个手势识别器,它使用两个手指向上或向下,就像Twitterific用于切换状态栏一样。

这是我的代码

[self.tableView setMultipleTouchEnabled:YES];
[self.tableView.panGestureRecognizer setMaximumNumberOfTouches:1];

UISwipeGestureRecognizer *swipeUpGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(doubleSwipeUp)];
[swipeUpGesture setNumberOfTouchesRequired:2];
[swipeUpGesture setDirection:UISwipeGestureRecognizerDirectionUp];
[swipeUpGesture setDelaysTouchesBegan:YES];
[self.tableView addGestureRecognizer:swipeUpGesture];

UISwipeGestureRecognizer *swipeDownGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(doubleSwipeDown)];
[swipeDownGesture setNumberOfTouchesRequired:2];
[swipeDownGesture setDirection:UISwipeGestureRecognizerDirectionDown];
[swipeUpGesture setDelaysTouchesBegan:YES];
[self.tableView addGestureRecognizer:swipeDownGesture];

我在viewDidLoad中调用它,并且没有调用doubleSwipeUp。

我该怎么办?

1 个答案:

答案 0 :(得分:0)

首先,我会检查以确保self.tableView.multipleTouchEnabled设置为YES。

如果这没有用,那么可以尝试设置swipeUpGesture.delaysTouchesBegan = YES;