devdoe
devdoe

Reputation: 4325

get Maximum COntent Offset in UItextVew iPhone

On Click of a button the data in my TextView is appended. I want that when content reaches the end of the textView it should scroll automatically.

The data is appended by "\n"'s so what I need is to set the rectTovisile to he maximum Content Offset , but I dont know how to get the maximum content offset.

If you have any oher method doProvide.

codeBehind:

- (IBAction) onLap
{   
    NSString *lapCatch = ......;

    myUITextView.text = [myUITextView.text stringByAppendingFormat:@"myData: %@ \n",lapCatch];
}

Upvotes: 1

Views: 306

Answers (1)

iDev
iDev

Reputation: 23278

Try with this,

if (myUITextView.text.length > 0) {
  NSRange range = NSMakeRange(myUITextView.text.length - 1, 1);
  [myUITextView scrollRangeToVisible:range];
}

Upvotes: 1

Related Questions