Objective c 工具栏隐藏在导航图像后面

Objective c 工具栏隐藏在导航图像后面,objective-c,ios,xcode,ipad,Objective C,Ios,Xcode,Ipad,我正在创建一个应用程序,其中我必须使用导航图像。 如果没有导航图像,我可以完美地看到工具栏选项 应用程序启动主屏幕上没有图像的导航栏 导航到第二页后的导航图像 现在,我正在使用在导航栏中添加图像 UIImageView *topBar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 45)]; topBar.image = [UIImage imageNamed:@"top_cell.png"]; [self.naviga

我正在创建一个应用程序,其中我必须使用导航图像。 如果没有导航图像,我可以完美地看到工具栏选项

应用程序启动主屏幕上没有图像的导航栏

导航到第二页后的导航图像

现在,我正在使用在导航栏中添加图像

UIImageView *topBar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 45)];
topBar.image = [UIImage imageNamed:@"top_cell.png"];
[self.navigationController.navigationBar addSubview:topBar];
现在,导航栏看起来就像在主屏幕上一样完美

但在第二页中,工具栏选项被隐藏

那么,如何在导航栏中的图像上方显示工具栏呢?

试试

[self.navigationController.navigationBar insertSubview:topBar belowSubview:navigationBar];
它将在导航栏下插入您的视图

第二种选择是在您的代码之后使用此代码:

[self.navigationController.navigationBar bringSubviewToFront: topBar]

这将使您的顶部栏位于视图堆栈的顶部。

最后,我找到了大量的工作。首先,我在
视图中添加了图像将出现
方法,然后,在
视图中添加工具栏后,我将出现
方法,如下代码所示

-(void)viewWillAppear:(BOOL)animated
{
//    self.navigationController.navigationBarHidden = TRUE;


///// Edit Hiren

UIImageView *topBar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 45)];
topBar.image = [UIImage imageNamed:@"top-bar.png"];
[self.navigationController.navigationBar addSubview:topBar];


}

-(void)viewDidAppear:(BOOL)animated
{
    toolbar.frame = CGRectMake(0, 0, 685, 44);
    // [toolbar sizeToFit];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolbar];
    //    [self.navigationController.view addSubview:toolbar];

}