UITextView not Scrolling in tvOS
I believe you want Indirect, not Direct touches. Here is how I set up my focusable, scrollable UITextView:
self.selectable = YES;
self.userInteractionEnabled = YES;
self.panGestureRecognizer.allowedTouchTypes = @[@(UITouchTypeIndirect)];
Here is what worked for me, in Swift 2.1:
myTextView.userInteractionEnabled = true
myTextView.selectable = true
myTextView.scrollEnabled = true
myTextView.panGestureRecognizer.allowedTouchTypes = [UITouchType.Indirect.rawValue]
Hope it helps.
Here's what worked for me in Swift 3.0.1, based on the previous answers:
- I had to subclass
UITextView
to overridecanBecomeFocused
to returntrue
- I had to set
panGestureRecognizer.allowedTouchTypes = [NSNumber(value: UITouchType.indirect.rawValue)]
- I had to set
isUserInteractionEnabled = true
in code - setting it in Interface Builder didn't seem sufficient - I had to check "Scrolling Enabled" in Interface builder (setting
isScrollEnabled = true
in code would also work
A few other niceties I found:
bounces = true
made scrolling feel more natural (had to be set in code; IB setting not respected)showsVerticalScrollIndicator = true
had to be set in code; IB setting not respected- Overriding
didUpdateFocus(in:with:)
to change the background color to visually indicate the focus.