导航控制器无法正常工作 [英] Navigation Controller not working properly

查看:63
本文介绍了导航控制器无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在当前应用程序中使用了导航控制器,但是iOS4和iOS5的导航控制器存在问题,因此我尝试为iOS 4和以下版本编写代码.5

I am using a navigation controller in my current application, but I had an issue with the navigation controller with the iOS4 and iOS5 so i tried to write the code for both iOS 4 & 5

if([[UINavigationBar class] respondsToSelector:@selector(appearance)]) //iOS >=5.0
{
    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
else
{
    self.navigationController.navigationBar.layer.contents = (id)[UIImage imageNamed:@"header.png"].CGImage;
}

但是问题是,当我在iOS 4版本上运行我的应用程序时,导航控制器看起来像这样.

But problem is when I run my app on iOS 4 version my navigation Controller look like this.

请建议我.

推荐答案

UINavigationController *navControl;

在其他部分,尝试这样.

In else part, try like this.

UINavigationBar *navBar = self.navControl.navigationBar;
   UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
            imgView.image = [UIImage imageNamed:@"header.png"];
            [navBar addSubview:imgView];
            [imgView release];

这篇关于导航控制器无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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