Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You shouldn't have to subclass a UITextView at all, just use <code>UISwipeGestureRecognizer</code>. In your view controller, you'll add something like this:</p> <pre><code>//Updated for both left and right swipes //Create one gesture recognizer for the swipe left UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(actionToBePerformedOnSwipe:)]; swipe.direction = UISwipeGestureRecognizerDirectionLeft; [self.textView addGestureRecognizer:swipe]; //Then do the same for UISwipeGestureRecognizerDirectionRight </code></pre> <p>Your view controller will now be notified that the user swiped on the text view. Also, <a href="http://www.raywenderlich.com/6567/uigesturerecognizer-tutorial-in-ios-5-pinches-pans-and-more" rel="nofollow">this tutorial</a> might help clarify gesture recognizers. <strong>EDIT:</strong> You can query the gesture recognizer (in the sender argument of the action method) for its direction by checking <code>((UISwipeGestureRecognizer *)sender).direction</code>.</p> <p>However, if you want to go the UITextView route, you'll have to add a make the view controller the text view's delegate and add a method to represent the swipe. In your text view sub class's header, you'd add something like this:</p> <pre><code>@protocol SwipeableTextViewDelegate &lt;UITextView&gt; -(void)textViewReceivedLeftSwipe; -(void)textViewReceivedRightSwipe; @end </code></pre> <p>The custom text view would call these methods on the delegate when the swipes were received, and the delegate (your view controller) would perform whatever action you want.</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload