gpt4 book ai didi

ios - UIScrollView、PanGestureRecognizer 和 iOs 4

转载 作者:行者123 更新时间:2023-11-29 11:17:28 29 4
gpt4 key购买 nike

我有一个可滚动的 View ,我需要无需滚动主视图即可触发的手势识别器。

我用过这段代码:

UISwipeGestureRecognizer *upRecognizer = 
[[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(upSwipeHandle:)];
upRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
[upRecognizer setNumberOfTouchesRequired:2];
[controller.view addGestureRecognizer:upRecognizer];
[[controller.scrollView panGestureRecognizer]
requireGestureRecognizerToFail:upRecognizer];

但它似乎只适用于 iOS 5。我如何在 iOS 4 中使用相同的识别器?

最佳答案

我使用 UIGestureRecognizer 委托(delegate)方法解决了我的问题。

添加

upRecognizer.delegate = self;

和这个方法:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{

if ([gestureRecognizer isKindOfClass:[UISwipeGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
return YES;
}

return NO;
}

关于ios - UIScrollView、PanGestureRecognizer 和 iOs 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8808292/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com