How to enable swipe gestures for UITextView

How to enable finger gesture recognition for UITextView?

This is my code, and the event attached to it does not fire. It works for cranes, not for checks.

// Add swipe support for easy textview content clean up
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(eraseTextWithSwipe:)];
[targetContent addGestureRecognizer:swipe];
[swipe release];

How to do it?

+3
source share
2 answers

I found a solution that works well for me.

You need to install a delegate (referring to the code above)

swipe.delegate = self;

then you need to add a delegate to track multiple gestures that can track scrolling and scrolling

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGesture
{
    yourTextbox.scrollEnabled = NO;
    return YES;
}

enable scrolling again in the callback function (in the example above eraseTextWithSwipe)

+2
source

. . YES . , UITextView.

+2

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


All Articles