gpt4 book ai didi

ios - UILongPressGestureRecognizer 和 UITextField 不能一起工作

转载 作者:行者123 更新时间:2023-11-28 22:47:43 24 4
gpt4 key购买 nike

我有一个带有 LongPressGesturerecognizer 的 UIViewController。 View Controller View 中还有一个 UITextField。

如果我点击 UITextField,Gesturerecognizer 会捕获长按。无法复制、粘贴、移动光标。

我想让 Gesturerecognizer 在 View 中的任何地方都处于事件状态,但 UITextField 除外,我希望在 UITextField 中使用默认的操作系统行为,如复制、粘贴、移动光标等。

这可能吗?我能以某种方式告诉手势识别器将手势转发到 UITextFields 默认值吗?

最佳答案

您必须为您的 UILongPressGestureRecognizer 设置委托(delegate)并实现 gestureRecognizer:shouldReceiveTouch: 委托(delegate)方法,如下所示:

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return touch.view != self.textField;
}

关于ios - UILongPressGestureRecognizer 和 UITextField 不能一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12786749/

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