Sabby
Sabby

Reputation: 2592

Text cut off in UitextView? How to scroll text page by page properly

I am trying to scroll text in UITextView manually up and down with the help of uibuttons. This is how I am doing.

[storyTextView setContentOffset:CGPointMake(storyTextView.contentOffset.x, scrollPoint-scrollFraction) animated:NO];

Where

scrollPoint=storyTextView.frame.size.height;

When I scroll up or down, text goes cut off.

See this image:

Upvotes: 2

Views: 2229

Answers (2)

Lithu T.V
Lithu T.V

Reputation: 20021

Try this

[storyTextView setContentInset:UIEdgeInsetsMake(5, 0, 5, 0)];

Ok the problem is like this.Your font size is large and mathematically you are setting up the content offset but only depends on the textview frame not the contents height.

Solution is to find out a proper algorithm to get the contents properly visible and then apply the content offset and then move with that specific height such that the text appears correctly.

Upvotes: 0

Johan Andersson
Johan Andersson

Reputation: 151

A UITextView clips it's subviews by default, so either you resize your UITextView to fill as much as you want, or you uncheck "Clip Subviews" in your xib, or with code

[storyTextView setClipsToBounds:NO];

Upvotes: 2

Related Questions