我使用下面的代码在导航栏上显示uiimage
-(void)hideTopBanner:(bool)b;
{
if(b)
{
[UIView animateWithDuration:0.35 animations:^{
UIView *bannerView =[self.navigationController.navigationBar viewWithTag:999];
[bannerView setFrame:CGRectMake(-320, 8, 144, 30)];
}];
}
else {
[UIView animateWithDuration:0.35 animations:^{
UIView *bannerView =[self.navigationController.navigationBar viewWithTag:999];
[bannerView setFrame:CGRectMake(88 , 8, 144, 30)];
}];
}
}
// --------------
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"topbg1.png"]] ;
[bgImageView setFrame:CGRectMake(0, 0, 320, 46)];
[self.navigationController.navigationBar addSubview:bgImageView];
bgImageView.tag=999;
[bgImageView release];
我尝试使用
UIBarButtonItem *myBarButtonItem = [[UIBarButtonItem alloc] init];
myBarButtonItem.title = @back"; // or whatever text you want
self.navigationItem.backBarButtonItem = myBarButtonItem;
[myBarButtonItem release];
显示后退按钮,但没有显示
但是当它导航到另一个视图控制器时。 导航栏上的后退按钮消失。
欢迎任何评论
答案 0 :(得分:0)
确保您的新视图控制器(您导航到的视图控制器)具有标题。当我的观点未设置标题时,我遇到了这个问题。
答案 1 :(得分:0)
如果一切都失败(设置标题等),请使用:
UIBarButtonItem *myBarButtonItem = [[UIBarButtonItem alloc] init];
[myBarButtonItem addTarget:self action:@selector(myBarButtonItemPressed) forControlEvents:UIControlEventTouchUpInside];
myBarButtonItem.title = @"back"; // or whatever text you want
self.navigationItem.leftBarButtonItem = myBarButtonItem;
[myBarButtonItem release];
- (void)myBarButtonItemPressed
{
// Do your stuff, like pop view controller
}