Reputation: 478
I have done my research and couldn't find a solution that fixed the problem.
I have set self.automaticallyAdjustsScrollViewInsets = false
I have a uitextview and i am setting the text on the viewDidLoad.
When the view appears, the textview appears partially scrolled.
If i breakpoint on the ViewDidAppear i see the the contentOffset.y is set but changing the text in textview results in a different contentOffset.
I'm using autolayout and i think that the constraints may be causing the problem.
The only code i have is setting the text in the uitextview
Upvotes: 3
Views: 3218
Reputation: 620
In my case, I needed to go a step further than nate-cook's answer. The text was still offset by -64 (below the bottom bounds of the textview) so i set the content offset later on the main thread:
DispatchQueue.main.async { [unowned self] in
self.textViewOrderInfo.setContentOffset(.zero, animated: false)
}
Upvotes: 0
Reputation: 478
i deleted the controller in the storyboard and rebuilt it and it just works now..
Upvotes: 0
Reputation: 93276
I think I've seen this before, too - right after you set the text of the textview, try resetting the content offset to zero:
textView.setContentOffset(CGPointZero, animated: false)
Upvotes: 4