ios - 检测底层 UITableViewCell 上的触摸并点击 UITextview 的属性文本

标签 ios objective-c uitableview uitextview textkit

我使用的 UITextView 附加到 UITableViewCell,其配置如下所示:

cell.topicAndDescriptionTextView = [[UITextView alloc] initWithFrame:frame];
cell.topicAndDescriptionTextView.tag = 1;
cell.topicAndDescriptionTextView.attributedText = attrText;    
cell.topicAndDescriptionTextView.scrollEnabled = NO;
cell.topicAndDescriptionTextView.editable = NO;
cell.topicAndDescriptionTextView.textContainer.lineFragmentPadding = 0;
cell.topicAndDescriptionTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
cell.topicAndDescriptionTextView.backgroundColor =[UIColor clearColor];
[cell.topicAndDescriptionTextView setUserInteractionEnabled:YES];
cell.topicAndDescriptionTextView.dataDetectorTypes = UIDataDetectorTypeAll;

现在我想使用文本工具包功能来检测我的属性文本 ( http://www.raywenderlich.com/48001/easily-overlooked-new-features-ios-7#textViewLinks ) 和 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 以在客户单击 UITableViewCell 中没有自定义链接的某处时识别下钻。

不幸的是 [UITextView setUserInteractionEnabled:YES] 使 textview 吞下所有触摸。实现这一目标的最佳方法是什么?我想编写一个自定义的 UITextView 类,并使用 UITextView 委托(delegate),但是我如何才能确定父类(super class)是否已经处理了对链接的按下并阻止向下钻取?

谢谢,

一月

最佳答案

如果返回的 View 是用于链接按钮的 View ,我会尝试覆盖 hitTest 并仅返回命中 View 。在其他情况下返回零。然后触摸被传递到 TableView ,滚动继续工作。

关于ios - 检测底层 UITableViewCell 上的触摸并点击 UITextview 的属性文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24292544/

相关文章:

ios - Xcode 自动布局不适用于所有设备

ios - UITableViewCell 中的自定义 UIView 阻止 uitableviewcell 接收事件

objective-c - 如何访问 NSBitmapImageRep 的像素?

ios - UITableView 中的 UILabel 被覆盖

ios - 如何防止分组 UITableViewCell 顶部的阴影在选中时出现和消失

ios - 滚动时 UITableViewCell 内容发生变化,因为在其中一个单元格中运行计时器

c# - MonoTouch 的 QR 库?

ios - 元视口(viewport)在 iOS 设备上的 iframe 中不起作用

ios - 修改核心数据模型每次都需要新版本?

ios - 查找从服务器接收到的数据的文件类型