我使用的 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/