UITextView不在tvOS中滚动 [英] UITextView not Scrolling in tvOS
问题描述
我的电视应用中有一个 UITextView
,当我尝试使其可聚焦时,UI无法使其可聚焦,我无法滚动它。我读了一些关于它的问题,有些人说这是一个已知问题,我们应该使用故事板。实际上我正在使用故事板但仍无法使其工作。我还试图让它可选择
, scrollEnabled
和 userInteractionEnabled
然后最后也尝试了这行代码,但它们都没有工作。
I have a UITextView
in my TV app, when i try to make it focusable then the UI is not making it focusable and i am unable to scroll it. I read some questions about it and some says that its a known issue and we should use storyboards. Actually i am using storyboards but still unable to get this to work. I have also tried to make it selectable
, scrollEnabled
and userInteractionEnabled
and then finally also tried this line of code but none of them is working.
descriptionLbl.panGestureRecognizer.allowedTouchTypes = [NSNumber(integer: UITouchType.Direct.rawValue)]
我还试图打印界限
abd
,这是日志 UITextView
的contentSize
I also tried to print bounds
abd contentSize
of the UITextView
and here is the log
Content Size (740.0, 914.0)
Bounds (25.0, 0.0, 740.0, 561.0)
这是我的代码可以帮我一些
Here is my code can some body help me
@IBOutlet weak var descriptionLbl: UITextView!
var currentModel : Model?
override func viewDidLoad() {
super.viewDidLoad()
descriptionLbl.selectable = true
descriptionLbl.scrollEnabled = true
descriptionLbl.userInteractionEnabled = true
descriptionLbl.panGestureRecognizer.allowedTouchTypes = [NSNumber(integer: UITouchType.Direct.rawValue)]
descriptionLbl.text = (currentModel?.description)! + (currentModel?.description)! + (currentModel?.description)!
descriptionLbl?.contentInset = UIEdgeInsets(top: 0.0, left: -25.0, bottom: 0.0, right: 0.0);
}
我想我不应该这些许多技巧,但它没有任何作用。焦点实际上是 UITextView
,但它不会滚动。有什么想法?
i guess i should not be doing these many tricks but it is not working in any way. The focus is actually coming to UITextView
but it does not scroll. Any ideas?
推荐答案
我相信你想要间接,而不是直接接触。以下是我如何设置可聚焦,可滚动的UITextView:
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)];
这篇关于UITextView不在tvOS中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!