gpt4 book ai didi

objective-c - 在 UITextView 中禁用双击

转载 作者:搜寻专家 更新时间:2023-10-30 20:02:54 25 4
gpt4 key购买 nike

我想在 UITextView 中禁用双击。我已经禁用了长按:

- (void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
gestureRecognizer.enabled = NO;
}
[super addGestureRecognizer:gestureRecognizer];
return;
}

我尝试用 UITapGestureRecognizer 做同样的事情,但它也禁止单击。

- (void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
gestureRecognizer.enabled = NO;
}
if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
gestureRecognizer.enabled = NO;
}
[super addGestureRecognizer:gestureRecognizer];
return;
}

如何禁用仅双击?

我知道 numberOfTapsRequired 方法,但不知道如何在我的代码中应用它。

最佳答案

我建议您试试这个,而不是禁用您的点击手势识别器

if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
[(UITapGestureRecognizer *)gestureRecognizer setNumberOfTapsRequired:1];
}

通过这种方式,您应该启用单击并禁用双击。

关于objective-c - 在 UITextView 中禁用双击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17388865/

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