(iphone) non-editable UITextView “bookmark”
-
11-09-2019 - |
Question
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
Solution
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];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow