Search code examples
iphoneiosios4uiviewuinavigationcontroller

How to remove custom Navigation Bar image?


I'm using the code below to set a background to a navigation bar. It worked but as I don't want it on all navigation bars, I have to remove it before leaving the current view. How to do it ?

- (void)viewDidLoad
{
   UIImageView *nav_img = [[UIImageViw alloc] initWithImage:[UIImage imageNamed:@"header-background.png"]];
   nav_img.frame = CGRectMake(0.0,0.0,320.0,44.0);
   [self.navigationController.navigationBar insertSubView:nav_img atIndex:0];
   [nav_img release];
}

Thx for helping,

Stephane


Solution

  • Add a tag to the image view as you add it. Use the viewWithTag: method to get a pointer to the image view and set the hidden property of the image view in your viewWillAppear and viewWillDisappear methods.