iPhone 中 iPhone OS 4.0 的导航栏中不可见后退按钮

发布于 2024-09-07 20:41:48 字数 635 浏览 5 评论 0原文

在我的应用程序(基于视图)中,后退按钮在导航栏中不可见。如果我单击该按钮,操作就会正常进行。这对我来说很奇怪。后退按钮在 iPhone OS 3.0 和其他操作系统中可见且正常工作。(OS 4.0 除外)。我目前使用 iPhone OS 4.0。

这是我的代码:

UIButton *btn=[[UIButton alloc] init];

[btn setImage:[UIImage imageNamed:@"Back.png"] forState:UIControlStateNormal];

[btn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
[btn setImageEdgeInsets:UIEdgeInsetsMake(0, 70, 0, 20)];
UIBarButtonItem *b=[[UIBarButtonItem alloc] initWithCustomView:btn];    
self.navigationItem.leftBarButtonItem=b;
[b release];
[btn release]; 

注意:它仅适用于 iPhone OS 4.0。那么我怎样才能实现这一目标呢?

In my application (View based), the back buttons are not visible in the navigation bar. If I click that button, the actions works properly. It's very weird to me. The back button is visible and properly working in iPhone OS 3.0 and others.(Except OS 4.0). I am currently working in iPhone OS 4.0.

Here is my code:

UIButton *btn=[[UIButton alloc] init];

[btn setImage:[UIImage imageNamed:@"Back.png"] forState:UIControlStateNormal];

[btn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
[btn setImageEdgeInsets:UIEdgeInsetsMake(0, 70, 0, 20)];
UIBarButtonItem *b=[[UIBarButtonItem alloc] initWithCustomView:btn];    
self.navigationItem.leftBarButtonItem=b;
[b release];
[btn release]; 

Note: It doesn't work only iPhone OS 4.0. So how can I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

祁梦 2024-09-14 20:41:48

只需将这段代码替换到任何你想要的地方,它就可以在 OS 4.0 中正常工作。

UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];

UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];

[myView addSubview:btn];

UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,5,50,30)];

[myImage setImage:[UIImage imageNamed:@"Back.png"]];

[myView addSubview:myImage];

[btn addTarget:self action:@selector(lOut) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *b1 = [[UIBarButtonItem alloc] initWithCustomView:myView];

self.navigationItem.leftBarButtonItem = b1;

[btn release];

[b1 release];

[myView release];

[myImage release];

我希望它能帮助你。

Simply you replace this code wherever you want and its working fine in OS 4.0.

UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];

UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];

[myView addSubview:btn];

UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,5,50,30)];

[myImage setImage:[UIImage imageNamed:@"Back.png"]];

[myView addSubview:myImage];

[btn addTarget:self action:@selector(lOut) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *b1 = [[UIBarButtonItem alloc] initWithCustomView:myView];

self.navigationItem.leftBarButtonItem = b1;

[btn release];

[b1 release];

[myView release];

[myImage release];

I hope it will help ypu.

凉风有信 2024-09-14 20:41:48
UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 40)];
[btn setImage:[UIImage imageNamed:@"info44.png"] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:@"info44_glowing.png"] forState:UIControlStateHighlighted];   
[btn addTarget:[AppDelegate sharedAppDelegate]  action:@selector(settingAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *settingButton = [[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.leftBarButtonItem = settingButton;
[btn release];
[settingButton release];
UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 40)];
[btn setImage:[UIImage imageNamed:@"info44.png"] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:@"info44_glowing.png"] forState:UIControlStateHighlighted];   
[btn addTarget:[AppDelegate sharedAppDelegate]  action:@selector(settingAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *settingButton = [[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.leftBarButtonItem = settingButton;
[btn release];
[settingButton release];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文