在UITableViewCell中的UITextView上启用dataDetectorTypes [英] issue enabling dataDetectorTypes on a UITextView in a UITableViewCell

查看:114
本文介绍了在UITableViewCell中的UITextView上启用dataDetectorTypes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表格中的UITableViewCell中有一个UITextView。关闭UITextView的editable,这允许我将dataDetectorTypes设置为UIDataDetectorTypeAll,这正是我想要的。该应用程序现在检测用户何时触摸UITextView中的链接,并执行相应的操作。

I have a UITextView inside a UITableViewCell in a table. "editable" for the UITextView is turned off, which allows me to set dataDetectorTypes to UIDataDetectorTypeAll, which is exactly what I want. The app now detects when the user touches a link in the UITextView, and does the appropriate thing.

当用户触摸部分UITextView时会出现问题没有链接。我希望调用UITableView委托中的didSelectRowAtIndexPath。但它不是,因为即使没有检测到链接,UITextView也会捕获触摸。

The problem arises when the user touches on part of the UITextView where there is no link. I want the didSelectRowAtIndexPath in the UITableView delegate to be called. But it isn't, because the UITextView is trapping the touch, even when no link is detected.

我的第一个猜测是将UITextView上的userInteractionEnabled变为NO。这意味着将调用didSelectRowAtIndexPath,但是UITextView无法检测到链接。这是一个问题22。

My first guess was to turn userInteractionEnabled on the UITextView to NO. This means that didSelectRowAtIndexPath will get called, but then the UITextView can't detect links. It's a catch-22.

关于如何解决这个问题的想法?

Any ideas on how to fix this?

感谢您的帮助。

推荐答案

也许你可以尝试通过触摸响应器链。

Maybe you could try passing the touch up the responder chain.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
   [super touchesBegan:touches withEvent:event];
}

这篇关于在UITableViewCell中的UITextView上启用dataDetectorTypes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆