Reputation: 1043
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
Reputation: 1695
You also try
self.textView.scrollRangeToVisible(NSRange(location:0, length:0))
Upvotes: 0
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