简体   繁体   English

iOS-UITextView上的链接不适用于UIScrollView

[英]iOS - Links on UITextView don't work with UIScrollView

I have a UITextView on a UIScrollView. 我在UIScrollView上有一个UITextView。 The text view contains a few links.The links don't work if the text view is originally outside screen and scrolled into view. 文本视图包含一些链接。如果文本视图最初位于屏幕外并滚动到视图中,则这些链接不起作用。 If the textview is originally in the screen, the links work fine. 如果textview最初在屏幕上,则链接可以正常工作。

Anyone knows the solution for that? 有人知道解决方案吗?

I got the solution myself. 我自己找到了解决方案。 It was the height of the content UIView on the UIScrollView that was making the problem. 问题的原因在于UIScrollView上内容UIView的高度。 The content view's height was equal to the scrollview's height. 内容视图的高度等于滚动视图的高度。 But, the subviews' total height was a lot larger. 但是,子视图的总高度要大得多。 Although everything seems displayed correctly, user interactions outside the content view's bounds was not passed to subviews properly. 尽管所有内容似乎都正确显示,但未将内容视图范围之外的用户交互正确传递给子视图。

So, I override viewWillLayoutSubviews and manually update the content view's height constraint. 因此,我重写了viewWillLayoutSubviews并手动更新了内容视图的高度约束。 The links are working fine now. 链接现在工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM