views:

348

answers:

1

Hi,

I am new to iphone dev and I'm trying to create a "bookmark" in an NON-editable UITextView. More specifically - I go to the view with the UITextView, scroll maybe halfway(or to some other point) through the text, leave that view and when I come back the UITextView is showing where I left off.

I have everything figured out except how to 'capture' the point that the NON-editable UITextView is scrolled to when leaving the view. I've tried selectedRange in viewWillDisappear in every way I could think of.

Any ideas on this would be greatly appreciated, I've been struggling for almost two days.

I hope I'm explaining that clearly enough.

Thanks in advance!! GL

A: 

h

UITextView *txtView;
CGPoint position;

m

-

-(void) savePosition
{
  position = txtView.contentOffset;
}


    -(void) restorePosition
    {
        CGRect r = CGRectMake(position.x, position.y, txtView.contentSize.width,  txtView.contentSize.height);
        [txtView scrollRectToVisible: r animated: NO]; 

    }
oxigen
Thanks! I can't get it to work though. I am very new to this. Is there anything else I need to do here other than insert the code in the appropriate pages? I've tried a bunch of different things with no luck. Thanks again!
GL777
by the way, that worked. Thanks!
GL777