我在 UIScrollView 中有一个 UIView demoView。我想垂直滚动 UIScroll 视图而不是水平滚动。我将 UISwipeGestureRecognizer 添加到 UIView。代码是(这里的self是UIScrollView):
self.demoView.userInteractionEnabled = YES;
UISwipeGestureRecognizer *rightSwipe = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(rightSwipeLineChart:)];
rightSwipe.direction = UISwipeGestureRecognizerDirectionRight;
[self.demoView addGestureRecognizer:rightSwipe];
UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(leftSwipeLineChart:)];
[self.demoView addGestureRecognizer:leftSwipe];
结果是我只能检测到左滑动手势,无法检测到右滑动手势。我的代码有什么问题?谢谢你。