demo功能:读取epub电子书的阅读器demo,可以更改字体大小,查询,按电子书章节索引。
demo说明:按照epub结构读取内容并显示。主要使用webview显示内容,章节内用js制作的翻页效果(效果不是很好,有点闪烁)。主要代码在:EPubViewController.m中。
demo截屏:
demo的主要代码:翻页控制部分
- (void) chapterDidFinishLoad:(Chapter *)chapter{
totalPagesCount+=chapter.pageCount;
if(chapter.chapterIndex + 1 < [loadedEpub.spineArray count]){
[[loadedEpub.spineArray objectAtIndex:chapter.chapterIndex+1] setDelegate:self];
[[loadedEpub.spineArray objectAtIndex:chapter.chapterIndex+1] loadChapterWithWindowSize:webView.bounds fontPercentSize:currentTextSize];
[currentPageLabel setText:[NSString stringWithFormat:@"?/%d", totalPagesCount]];
} else {
[currentPageLabel setText:[NSString stringWithFormat:@"%d/%d",[self getGlobalPageCount], totalPagesCount]];
[pageSlider setValue:(float)100*(float)[self getGlobalPageCount]/(float)totalPagesCount animated:YES];
paginating = NO;
NSLog(@"Pagination Ended!");
}
}
- (int) getGlobalPageCount{
int pageCount = 0;
for(int i=0; i<currentSpineIndex; i++){
pageCount+= [[loadedEpub.spineArray objectAtIndex:i] pageCount];
}
pageCount+=currentPageInSpineIndex+1;
return pageCount;
}
- (void) loadSpine:(int)spineIndex atPageIndex:(int)pageIndex {
[self loadSpine:spineIndex atPageIndex:pageIndex highlightSearchResult:nil];
}
- (void) loadSpine:(int)spineIndex atPageIndex:(int)pageIndex highlightSearchResult:(SearchResult*)theResult{
webView.hidden = YES;
self.currentSearchResult = theResul