David P
David P

Reputation: 1043

UITextView scroll bug iOS9 xcode 7.1.1

I have a simple UITextView that occupies all the screen. When the text length is bigger than the Textview height, it automatically scrolls to the bottom (see image).

I have already tried

self.textView.scrollRangeToVisible(NSMakeRange(0, 0))

and

self.textView.scrollsToTop = true

and other things without any result.

I'm using iOS 9 with the latest swift and Xcode 7.1.1.

Upvotes: 2

Views: 673

Answers (2)

Manuel
Manuel

Reputation: 1695

You also try

 self.textView.scrollRangeToVisible(NSRange(location:0, length:0))

Upvotes: 0

David P
David P

Reputation: 1043

I've found a solution.

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    self.textView.setContentOffset(CGPoint.zero, animated: false)
}

but I still don't understand why it didn't work.

Upvotes: 1

Related Questions