問題描述
iOS:如何跟踪用戶製作的書籤? (iOS: How to keep track of the bookmarks the user makes?)
guys. I'm working on my book app and I have trouble keeping track of the bookmarks the user makes. My app works fine if the font is fixed, but I want to allow the user to change the font size. For example, the user makes a bookmark on page 16, but he makes the font size bigger, so the last part of the text on page 16 is pushed to the next page. When he comes back to the text he wants to read, he won't find it on page 16 because it will be in page 17.
Here is my question: How can I keep track of the bookmarks the user makes? I would appreciate it if someone gave me some tips on this.
參考解法
方法 1:
It would make the bookmark by range. That way, if you want to bookmark by the contents of the entire page, you can save the range of the visible text (detailed here), or you could bookmark by a smaller selection of text. Either way, you'll be storing the bookmark in the form of a NSRange.
Then when it comes time to jump to the bookmark, you can simply use UITextView's scrollRangeToVisible:.
[textView scrollRangeToVisible:<#(NSRange)#>];
(by boochan224、Mick MacCallum)