1

以下に示すような構成で に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]、テキストビューはすべてのタッチを飲み込みます。これを達成するための最良のアプローチは何ですか?カスタムUITextViewクラスを作成してUITextViewデリゲートを使用することを考えましたが、スーパー クラスがリンクのプレスを既に処理しているかどうかを特定し、ドリルダウンをブロックするにはどうすればよいでしょうか。

THX、

1月

4

2 に答える 2

1

hitTest をオーバーライドして、返されたビューがリンク ボタンに使用されるビューである場合にのみヒット ビューを返すようにします。それ以外の場合は nil を返します。次に、代わりにタッチがテーブルビューに渡され、スクロールが機能し続けます。

于 2014-06-18T20:01:17.383 に答える