如何使scrollView可以在tvOS中滚动?

时间:2019-04-26 03:00:17

标签: swift uiscrollview uitextview tvos

我使用UITextView来显示一些文本内容,但是我发现UITextView无法滚动以显示更多内容,因此我决定给我们一个scrollView添加textview作为它的subView。但是我发现它不起作用,该怎么办?

import UIKit

class ViewController: UIViewController {
var scrollView: UIScrollView?
var textView: UITextView?
override func viewDidLoad() {
    super.viewDidLoad()
    scrollView = UIScrollView(frame: CGRect(x: 100, y: 100, width: UIScreen.main.bounds.size.width - 200, height: 500))
    textView = UITextView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 200, height: CGFloat.greatestFiniteMagnitude))
    textView?.text = "huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334huygfiuewfbjdbaskrgywfgqabsdjbaurguyfgsafhvdfjgiy3fdshfvdsfgq lieyouiegfhdskfkuwtrogfdsfsdfgwuyro8efgogfef334"
    textView?.sizeToFit()
    scrollView?.contentSize = textView!.frame.size
    scrollView?.addSubview(textView!)
    scrollView?.isScrollEnabled = true
    view.addSubview(scrollView!)
  }
}

0 个答案:

没有答案