I am getting some issue with using a bluetooth keyboard to UIPanGestureRecognizer which is used for scrolling a textview. Do I need a different recognizer to detect up and down arrows?
Asked
Active
Viewed 99 times
1 Answers
2
If you're wanting to scroll a text view, the text view already has a built-in gesture that listens for keyboard events (or any other UIPress
event), you just need to enable it.
textView.directionalPressGestureRecognizer.enabled = YES;
Same thing for using touches to scroll it: the text view's built-in pan gesture can recognize those touches, but it doesn't by default on tvOS. That's because the normal use-case on TV is for touches to move focus, not scroll the scroll view. You can get the pan gesture to listen to touches by changing it's allowedTouchTypes
like so:
textView.panGestureRecognizer.allowedTouchTypes = @[ @(UITouchTypeIndirect) ];

Justin Voss
- 6,294
- 6
- 35
- 39
-
thanks, this lead me to this https://forums.developer.apple.com/thread/19184 which solved my problem by adding the directionalPressGestureRecognizer to the parent view. – Frank Jun 27 '16 at 22:21