issue enabling dataDetectorTypes on a UITextView in a UITableViewCell

后端 未结 2 377
面向向阳花
面向向阳花 2021-01-24 17:24

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

相关标签:
2条回答
  • 2021-01-24 17:49

    Override all four of the UIResponder touch handlers to forward to the text view's superview.

    The header file states that "Generally, all responders which do custom touch handling should override all four of these methods. … You must handle cancelled touches to ensure correct behavior in your application. Failure to do so is very likely to lead to incorrect behavior or crashes."

    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 讨论(0)
  • 2021-01-24 17:56

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

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
       [super touchesBegan:touches withEvent:event];
    }
    
    0 讨论(0)
提交回复
热议问题