I'm using UITextView to display a text read from XML file. On click of a button, it will read next entry from XML file and replaces text in text view accordingly. Its working fine. But the trouble is that, some times, the text starts at 0,0 location in text view and some times, its leaving some space at the top of text view and displaying text. How can I force text to align to the top of text view. Also how can I make text view to leave some padding at the开发者_如何学运维 top?
I have something similar with scrollable images loading based on user input, which may or may not help. Every time the user changes the image I call:
[YourTextView setContentOffset:CGPointZero];
It might help reset the positioning of the text view.
Use this :
self.nameTextView.contentInset = UIEdgeInsetsMake(0,0,0,0);
did you try with [<#Your textview#> sizeToFit];
精彩评论