ios reader html,ios - epub reader to handle big html file - Stack Overflow

I am creating an epub reader on IOS platform. Basically, it uses UIWebview to display epub files, I read the code of open source Aepubreader and find it's very good but not text based. I want to make it text based and page turn like iBooks.

So I try to refine the Aepubreader

The basic logic flow is

unzip the epub file.

parse the meta data(opf,toc file).

load html files by UIWebView and bind it to UIPageViewController

Everything works good except the performance.

Supposing the epub has ten html files(file1 - file10). file1 ~ file9 is small size(like 100k), but file 10 is 1MB.

when I read to the first page of file10, it costs a lot time to load this 1MB file. That's acceptable since it's the first time.

But when I turn to the second page of file10. I still need to load this 1MB file again and call a js to scroll offsetx by page number.(no way to copy a UIWebView per Apple Offical Document). This is not acceptable. I can't let user always wait when turn page on this file.

Finally I got a solution to avoid reloading this big file.

When I get first page of file10 displayed. I capture this visible view as an image, but not display it, when I turn to next page, I display this image for the page1, in the meanwhile , I give the UIwebview to from page1 to page2. like Page2.view.addSubview(webviewfrompage1). this will avoid reload webview and save time.

But, another problem is coming, Page2.view.addSubview(webviewfrompage1) will cause page2 layoutsubview, which means page2 will redraw its view to show the webview content. This is a 1MB file content, redraw still cost time, and it'll stuck the page turn animation.

I searched a lot but still have no solution.

I check the iBooks, it works perfect. How did it hanle the big file?

Please let me know if you have any thoughts on this. or other solution to handle epub display.

Thanks in advance

---------------------------------------------------------------------------------------------

reply to torazaburo:

Yes, you are absolutely right. I planned to use window.scroll(offsetX, offsetY) to get next page content.

But that's not enough. I want the page turn animation just like ibooks. So I use UIPageViewController. Using UIPageViewController means I have to implement following two delegates

-(UIViewController *)pageViewController: (UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {

}

(UIViewController *)pageViewController: (UIPageViewController *)pageViewController viewControllerBeforeViewController: (UIViewController *)viewController{

}

In each deleagte, I need to alloc a viewcontroller, reload the url and set offset to location proper page. So Every time page turn, it's not just

set offset for content but alloc a new uiwebview and reload url then set offset.

torazaburo, what do you think?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值