I am using a UITextView
to display the text from a xml
.I parsed the xml and stored the text in a NSArray
and from there i am adding it to a UITextview
in my code.
problem: When i run the code the textview shows as empty or with partial text,and when i try to scroll the textview the whole text is getting displayed.
I added the UITextview
to a UIView
.
i found it strange and googled it but could not find many answers which helps me. Can someone reply me to solve the issue
TNQ
Found a simple SOLUTION
Had the same problem. When you put text into a UITextView which is not visible, it doesn't draw the text.
I had my UITextView off screen and animated it in like this:
[UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationCurveEaseOut animations:^{
self.contentView.center = CGPointMake(self.contentView.center.x + move * (self.contentView.frame.size.width /2), self.contentView.center.y);
self.textView.frame = self.textView.frame; // <<<--- ADD THIS LINE
} completion:^(BOOL finished) {
if (finished) {
}
}];
When you re-set the textview's frame, it re-draws it's text. So all you need to do is add the line I marked above before your UITextView comes on screen.
Cheers
UITextView inherits from UIScrollView, so just scroll it.
[detailsTextView setContentOffset:CGPointMake(0, 1) animated:YES];
i solved the issue by clearing the textview and added the text to the textview again,i dont know the exact funda but my issue is solved. in my case: i am changing the frame of the textview from outside to the view on click of a button.while the button is clicked the textview is not showing content and on scroll it shows.
i solved, by deleting the text from textview and re entering the text on clicking the button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With