2017-04-20 17 views
0

UIScrollViewをWebサイトのように通常のスクロールウィンドウのように動作させることはできますか?スクロールビュー内のさまざまなUIViewに焦点を当ててスクロールしないことを意味します。私は可変の高さで展開する長いUITextViewを持っていて、私は通常スクロールしてテキストを読むのが好きです。UITextViewを使用するUIScrollViewのApple TVのデフォルトスクロール動作

しかし、UITextViewをUIScrollViewに追加すると(どちらも指定されたcontentSizeで)、結果は得られません。

実装さ:

//:: Scroll View 
    scrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: 1920, height: 1080)) 
    scrollView.autoresizingMask = [.flexibleHeight] 
    scrollView.translatesAutoresizingMaskIntoConstraints = true 
    scrollView.backgroundColor = UIColor.red 


    scrollView.addSubview(txtView) 
    view.addSubview(scrollView) 

    //:: Anchor 
    txtView.translatesAutoresizingMaskIntoConstraints = false; 
    txtView.topAnchor.constraint(equalTo: view.topAnchor, constant: 120).isActive = true 
    txtView.centerXAnchor.constraint(equalTo: view.centerXAnchor, constant: 0).isActive = true 
    txtView.widthAnchor.constraint(equalToConstant: 825).isActive = true 
    txtView.contentSize = CGSize(width: 825, height: 2000) 
    txtView.clipsToBounds = false 

    scrollView.isScrollEnabled = true 
    scrollView.showsVerticalScrollIndicator = true 
    scrollView.contentSize = CGSize(width: 1920, height: 2000) 

答えて

0

はUIScrollViewの広告はUITextViewにスクロール可能に取り除くように簡単ました:

txtView.isScrollEnabled = true 

は、誰もがそれに答えていない驚きました。

関連する問題