1
    UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];
[self.view addGestureRecognizer:rightRecognizer];

UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
leftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[leftRecognizer setNumberOfTouchesRequired:1];
[self.view addGestureRecognizer:leftRecognizer];

我在 viewDidLoad 方法上添加了滑动手势,我有多个向左和向右滑动的视图,在包含表格的视图上,当表格有数据时,左右手势工作正常,但是在空表格手势不起作用的情况下。

有什么建议..?

注意:它在模拟器中工作,但不在设备上。

4

1 回答 1

7

问题可能是因为我添加了两个手势,最后一个代表帮助了我。现在代码正在运行。

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
     { 
        return YES; 
     }
于 2013-09-11T07:46:05.597 回答