UITextView starts at Bottom or Middle of the text

后端 未结 19 1561
谎友^
谎友^ 2020-12-04 13:09

I\'ll get right to it. I have a UItextView placed in my view that when needs to scroll to see all the text (when a lot of text is present in the textView) the t

19条回答
  •  自闭症患者
    2020-12-04 13:31

    In my case I was loading a textView in a Custom tableview cell. Below is what I did to make sure the text in a textview loads at the top of the text in my textview in my custom cell.

    1.) In storyboard, set the textview ScrollEnabled = false by unchecking the button.

    2.) You set the isScrollEnabled to true on the textview after the view loads. I set mine in a small delay like below:

    override func awakeFromNib() {
        super.awakeFromNib()
    
    let when = DispatchTime.now() + 1
          DispatchQueue.main.asyncAfter(deadline: when){
            self.textView.isScrollEnabled = true
         }
    
    }
    

    Regardless, if you are in my situation or not, try setting scrollEnabled to false and then when the view loads, set scrollEnabled to true.

提交回复
热议问题