【发布时间】:2014-03-16 04:43:25
【问题描述】:
我也问过这个问题here,但我没有得到任何解决方案。所以我再次在这里询问完整的解释。
我从here 下载了 EPub Reader 库。当我运行这个库时,首先出现一个表格视图,其中包含四行,其值为 EPUB、PDF 等,然后单击“EPUB”行 book 成功出现在顶部工具栏上。因为我必须在开始时首先加载这本书而不是显示工具栏,所以我对代码做了一些更改。从 didSelectRowAtIndexPath 复制一些代码并将该代码添加到 delegate.m 中。所以现在的问题是书籍已成功加载,但工具栏未显示
这是我的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [userDefaults objectForKey:@"AppleLanguages"];
EPubViewController *epubView = [[EPubViewController alloc] init];
[epubView loadEpub:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"AtoZbook" ofType:@"epub"]]];
self.navigationController = [[UINavigationController alloc]initWithRootViewController:epubView];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
加载epubView的代码在原库的RootViewController.m中
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
//TXT
case 0:{
//txt
}
break;
//PDF
case 1:{
//PDF
}
break;
//EPUB
case 2:{
epubView = [[EPubViewController alloc] init];
[epubView loadEpub:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"The Chessmen of Mars" ofType:@"epub"]]];
epubView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:epubView animated:YES];
[epubView release];
}
break;
case 3:{
//another book
}
break;
default:
break;
}
}
这是我对 EpubViewController 的 didLoadMethod 的看法
- (void)viewDidLoad {
[super viewDidLoad];
loadingIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
loadingIndicator.center = CGPointMake(toolbar.frame.size.width/2 ,toolbar.frame.size.height/2);
[loadingIndicator startAnimating];
toolbar.alpha = 0.8;
[self.toolbar addSubview:loadingIndicator];
[webView setDelegate:self];
UIScrollView* sv = nil;
for (UIView* v in webView.subviews) {
if([v isKindOfClass:[UIScrollView class]]){
sv = (UIScrollView*) v;
sv.scrollEnabled = NO;
sv.bounces = NO;
}
}
currentTextSize = 100;
//Webview
UISwipeGestureRecognizer* rightSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoNextPage)] ;
[rightSwipeRecognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
UISwipeGestureRecognizer* leftSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPrevPage)] ;
[leftSwipeRecognizer setDirection:UISwipeGestureRecognizerDirectionRight];
[webView addGestureRecognizer:rightSwipeRecognizer];
[webView addGestureRecognizer:leftSwipeRecognizer];
[self performSelector:@selector(stratRolling)];
}
这是图片
我想再说一遍,当我从Case 2 显示 epubViewController 时,工具栏可以正常工作,我的意思是如果我必须先显示表格视图,请单击该行。
【问题讨论】:
标签: ios iphone objective-c uinavigationitem epub