Reputation: 111
I use a UITextView
that is attached to a UITableViewCell
with a configuration as shown below:
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;
Now I would like to use text kit feature to detect taps on custom links in my attributed text (http://www.raywenderlich.com/48001/easily-overlooked-new-features-ios-7#textViewLinks) and - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
to identify a drilldown if a customer clicks somewhere in the UITableViewCell
where there is no custom link.
Unfortunately [UITextView setUserInteractionEnabled:YES]
makes the textview swallow all touches. What is the best approach to achieve this? I thought of writing a custom UITextView
Class, and use UITextView
delegates, but how can I then identify if the super class handles the press on a link already and to block a drilldown?
THX,
Jan
Upvotes: 1
Views: 384
Reputation: 111
I found the solution. I created my custom UITextView Class and override touchesBegan. Touches Began is only called if no link is clicked in UITextView. I played around with hitTest, but hitTest is called all the time and I can't determine if a link was touched or not inside the UITextView.
Upvotes: 0
Reputation: 8247
I would try to override hitTest and only return a hit view if the returned view is the one that is used for link buttons. In other cases return nil. Then the touch is passed to the table view instead and the scrolling keeps working.
Upvotes: 1