iOS-工具栏未显示在顶部 [英] IOS - toolbar is not appearing on top

查看:126
本文介绍了iOS-工具栏未显示在顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此处提出了这个问题,但我没有任何解决方案.所以我再次在这里要求完整的解释.

i have asked this question here also but i didn't get any solution.so i am asking here again with the full explanation.

我从此处下载了EPub Reader库.当我运行此库时,首先出现一个表格视图,该表格视图包含四行,各行的值分别为EPUB,PDF等,然后单击"EPUB"行 该书与顶部工具栏一起成功显示.因为我必须在开始时首先加载这本书,而不是显示工具栏,所以我对代码进行了一些更改.从didSelectRowAtIndexPath复制了一些代码,并将该代码添加到了proxy.m中.所以现在的问题是书已成功加载,但工具栏未显示

I downloaded EPub Reader library from here. When i run this library,first comes a table view which contain four rows having values EPUB ,PDF etc and after clicking on the "EPUB" row book appears successfully with the top toolbar. Because i have to load the book first in start instead of showing the toolbar i did some changes with the code. copied some code from didSelectRowAtIndexPath and added that code into delegate.m. so now the problem is book is successfully loading but the toolbar is not showing up

这是我的代码

- (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中

the code of loading epubView was in RootViewController.m in the original library

- (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的diddMethod方法

here is my view didLoadMethod of EpubViewController

- (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时,工具栏可以正常工作,这意味着如果必须首先显示表格视图,请单击该行.

i want to say again that the toolbar works fine when i show the epubViewController from the Case 2 i mean by clicking the row if i have to show the table view first.

推荐答案

您的工具栏一直隐藏在导航栏中,因为导航栏始终位于顶部,因此您可以将工具栏添加为导航栏的子视图,不确定是否会尽管最好的方法是使用导航栏并像左键,右键和标题之类的东西添加项目,但它还是可以工作的,或者您可以添加视图作为导航栏的子视图,我在示例代码之前就已经完成了

your tool bar is hiding being navigation bar since navigation bar is always on top you can add your tool bar as sub view of navigation bar i m not sure if it will work though best approch is use navigation bar and add item it it like left button right button and title stuff or you can add a view as subview of navigation bar i have done that before sample code

navBar=self.navigationController.navigationBar;


    [navBar addSubview:statusBar];
    statusBar.frame=f;

    self.navigationController.navigationBar.translucent = YES;

在这里statusBar是一个像您的工具栏一样设置的视图.

here statusBar was a view was set up like your tool bar same size.

这篇关于iOS-工具栏未显示在顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆