简体   繁体   English

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. 例如,用户在第16页上添加了一个书签,但是他使字体大小变大,因此第16页上的文本的最后一部分被推到下一页。 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. 当他回到想要阅读的文本时,在第16页上将找不到它,因为它将在第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. 如果有人给我一些提示,我将不胜感激。

在此处输入图片说明

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. 无论哪种方式,您都将以NSRange的形式存储书签。

Then when it comes time to jump to the bookmark, you can simply use UITextView's scrollRangeToVisible:. 然后,当需要跳转到书签时,只需使用UITextView的scrollRangeToVisible:。

[textView scrollRangeToVisible:<#(NSRange)#>];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM