I'm trying to handle touches on a iPhone's UITextView. I successfully managed to handle taps and other touch events by creating a subclass of UIImageViews for example and implementing the touchesBegan method...however that doesn't work with the UITextView apparently :(
The UITextView has user interaction and multi touch enabled, just to be sure...no no joy. Anyone managed to handle this?
UITextView (subclass of UIScrollView) includes a lot of event processing. It handles copy and paste and data detectors. That said, it is probably a bug that it does not pass unhandled events on.
There is a simple solution: you can subclass UITextView and impement your own touchesEnded (and other event handling messages) in your own versions, you should call[super touchesBegan:touches withEvent:event];
inside every touch handling method.
#import "MyTextView.h" //MyTextView:UITextView @implementation MyTextView - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"touchesBegan"); } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ [super touchesBegan:touches withEvent:event]; NSLog(@"touchesMoved"); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"****touchesEnded"); [self.nextResponder touchesEnded: touches withEvent:event]; NSLog(@"****touchesEnded"); [super touchesEnded:touches withEvent:event]; NSLog(@"****touchesEnded"); } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ [super touches... etc]; NSLog(@"touchesCancelled"); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With