Search code examples
iphoneuitableviewuitextviewdatadetectortypes

issue enabling dataDetectorTypes on a UITextView in a UITableViewCell


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.

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.

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?

Thanks for any help.


Solution

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

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