gpt4 book ai didi

objective-c - 在 UITextView 上用两根手指转发事件触摸

转载 作者:行者123 更新时间:2023-11-28 19:20:26 25 4
gpt4 key购买 nike

我需要在用户用两根手指触摸屏幕时应用一个函数。我的问题是屏幕有一个 UITextView

屏幕上还存在事件键盘,这就是通常的方法 (UITapGestureRecognizer) 不适用于此配置的原因。

我该怎么做?

谢谢。

最佳答案

您需要将 UITapGestureRecognizer 添加到 UITextView

这是你必须做的:

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(respondToTap)];

[singleTap setNumberOfTapsRequired:2];
[self.yourTextView addGestureRecognizer:tapRecognizer];


-(void)respondToTap{
//do whatever you have to when textfield is double tapped
}

关于objective-c - 在 UITextView 上用两根手指转发事件触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9348350/

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