在 UIWebview 上逐页显示 EPUB
我正在 iPad 上开发 EPUB 阅读器。所以,我遇到了问题。 我们知道 EPUB 不是分页格式。但是,我想一页一页地展示它。当然,字号大的话页数会多,字号小的话页数会少。
我想让它像 iBooks 一样。 怎么解决呢?
感谢您的关注。
I'm developing EPUB reader on iPad. So, I got a problem.
We know that EPUB is not a paged format. But, I want to show it page by page. Of course, it will be more pages if font size is larger, it will be less pages if font size is smaller.
I want to make it like iBooks.
How to solve it?
Thank you for attention.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须读入数据并根据您设置的规则布置文本。据我所知,UIKit 的文本控件中没有内置的用于分页内容的工具。
您可以尝试的一件事是使用 Web 视图通过 HTML 逐页显示您的内容。您可以使用 Javascript 获取页面上的指标,并逐渐在页面中添加或删除内容,直到它与您的指标匹配。在单独的线程中执行此操作,并让它在用户阅读第一页时分析 EPUB。作为一个额外的好处,这将使您能够使用 CSS 进行页面布局,这将使您能够很好地控制版式、行距等,同时可以轻松添加热链接目录等功能。
You're going to have to read in the data and lay out the text according to whatever rules you set up. As far as I know, there's no built-in facility for paging content in UIKit's text controls.
One thing you might try is to use a web view to display your content via HTML on a page-by-page basis. You can use Javascript to grab metrics on a page and gradually add or remove content from the page until it matches your metrics. Do it in a separate thread and have it analyze the EPUB while the user is reading the first page. As an added bonus, that would enable you to use CSS to do your page layout, which would give you some nice control over typography, line spacing, etc., while making it easy to add features like hotlinked tables of contents.