Issuing dataDetectorTypes permissions on a UITextView in a UITableViewCell

I have a UITextView inside a UITableViewCell in a table. The "editable" for the UITextView is disabled, which allows me to set the dataDetectorTypes to UIDataDetectorTypeAll, which is exactly what I want. The application now detects when the user touches the link in the UITextView and does the corresponding thing.

The problem occurs when the user touches the part of the UITextView where there is no link. I want didSelectRowAtIndexPath in the UITableView delegate to be called. But this is not so, because the UITextView captures the touch, even if no connection is detected.

My first guess was to include userInteractionEnabled in a UITextView in NO. This means that didSelectRowAtIndexPath will be called, but the UITextView will not be able to detect the links. This is trick-22.

Any ideas on how to fix this?

Thanks for any help.

+1
source share
2 answers

Maybe you could try to go through the chain of defendants.

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

Redefine all four sensory handlers UIResponderto go to text view supervision.

, " , , , ... , . ."

class MyTextView: UITextView {

    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        self.superview?.touchesBegan(touches, withEvent: event)
    }

    override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
        self.superview?.touchesMoved(touches, withEvent: event)
    }

    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        self.superview?.touchesEnded(touches, withEvent: event)
    }

    override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
        self.superview?.touchesCancelled(touches, withEvent: event)
    }

}
0

All Articles