Receive touch events in a UITextView

Apple does not provide touch event processing for UITextView. The project that I am developing includes notes that can be read and edited, and I use UITextView. Please help me with this problem - how can I get touch events for my project?

+3
source share
4 answers

I solved the problem using my own logic.

When reading, we add Custom Viewon top textviewand work with these methods:

(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

, . , .

, .

0

Apple UITextView UITextViewDelegate.

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITextViewDelegate_Protocol/Reference/UITextViewDelegate.html

, , UITextView , textViewShouldBeginEditing.

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView;

delegate UITextView, .

+4

. .

+1

Just wanted to add an answer to Kevin. UITextView inherits from UIScrollView. You should receive all events declared in the UIScrollViewDelegate protocol for a text view.

I got:

-(void)scrollViewDidScroll:(UIScrollView *)scrollView

when I declared my class as a UITextView delegate.

0
source

Source: https://habr.com/ru/post/1729363/


All Articles