Satyam
Satyam

Reputation:

UITextView Text alignmnet at Top

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?

Upvotes: 0

Views: 5598

Answers (3)

Niru Mukund Shah
Niru Mukund Shah

Reputation: 4733

did you try with [<#Your textview#> sizeToFit];

Upvotes: 0

Tulon
Tulon

Reputation: 4124

Use this : self.nameTextView.contentInset = UIEdgeInsetsMake(0,0,0,0);

Upvotes: 1

mjdth
mjdth

Reputation: 6536

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.

Upvotes: 3

Related Questions