IOS – 工具栏没有出现在顶部

我在这里也问过这个问题,但是我没有得到任何解决办法。所以我在这里再次问及完整的解释。

我从这里下载了EPUB Reader库。 当我运行这个库,首先来到一个表格视图,其中包含四个值的EPUB,PDF等行,并点击“EPUB”行书成功出现顶部的工具栏。 因为我必须首先加载图书,而不是显示工具栏,我对代码做了一些修改。 从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我的意思是通过单击行,如果我必须先显示表视图。

你的工具栏是隐藏的导航栏,因为导航栏总是在最上面,你可以添加你的工具栏作为导航栏的子视图im不知道它是否会工作,虽然最好的方式是使用导航栏,并添加项目它就像左边的button权利button和标题的东西,或者你可以添加一个视图作为导航栏的子视图,我已经做了之前的示例代码

 navBar=self.navigationController.navigationBar; [navBar addSubview:statusBar]; statusBar.frame=f; self.navigationController.navigationBar.translucent = YES; 

这里statusBar是一个视图被设置为像你的工具栏一样的大小。