1

我使用下面的代码在导航栏上显示 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];

显示后退按钮,但没有显示

但是当它导航到另一个视图控制器时。导航栏上的后退按钮消失。

欢迎任何评论

4

2 回答 2

0

If everything fails (setting title etc), use this:

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
}
于 2012-05-24T07:53:24.763 回答
0

确保您的新视图控制器(您要导航到的那个)有一个标题。当我的视图没有设置标题时,我遇到了这个问题。

于 2012-05-24T07:41:05.303 回答