Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6924559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:40:42+00:00 2026-05-27T10:40:42+00:00

In viewDidLoad I have a UINavigationBar with a custom background implemented in the following

  • 0

In viewDidLoad I have a UINavigationBar with a custom background implemented in the following way:

[self.navigationController.navigationBar insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:nav_bg_image]] atIndex:100];

On the top of the stack (call it RVC) I have the following complete code:

UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:navbar_image_logo]];
[self.navigationController.navigationBar insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:nav_bg_image]] atIndex:100];
[self.navigationItem setTitleView:logoView];
[logoView release];

This works brilliantly. However, when I push a new VC on the stack and use the same code in viewDidLoad

UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:navbar_image_logo]];
[self.navigationController.navigationBar insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:nav_bg_image]] atIndex:1];
[self.navigationItem setTitleView:logoView];
[logoView release];
UIBarButtonItem *hButton = [[UIBarButtonItem alloc] initWithTitle:@"Filters" style:UIBarButtonItemStylePlain target:self action:@selector(filtersAction)];
self.navigationItem.rightBarButtonItem = hButton;
[hButton release];

Neither the “Filters” button nor the titleView imageView appears. However, I know the filters button has been added to the UI because if I click in the area that it is supposed to appear, the action is performed.

Furthermore, when I drill down to a detail view DVC and go back, all of the sudden the titleView (logoView) appears!

I suspect that this is some sort of memory issue but I have not been able to resolve it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:40:43+00:00Added an answer on May 27, 2026 at 10:40 am

    There is a mention of the issue you are having with ordering at iDev Recipes How do iPhone apps Instagram/Reeder/DailyBooth implement custom NavigationBars with variable width back buttons?

    Basically you are adding your background in the wrong way.

    Support only iOS 5
    Implement a method like setBackgroundImage:forBarMetrics:

    Support Older iOS’s + iOS 5

    1. Subclass UINavigationBar and implement the drawRect

      //.h
      @interface CustomNavigationBar : UINavigationBar
      @end
      
      //.m
      @implementation CustomNavigationBar
      
      - (void)drawRect:(CGRect)rect;
      {
          UIImage *image = [[UIImage imageNamed: @"BackgroundImage"] stretchableImageWithLeftCapWidth:0 topCapHeight:0];
          [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
      }
      
      @end
      
    2. To get a UINavigationController to use your subclass you need to create it using a xib.

    enter image description here


    If you have set everything up in code then you will still need to use a nib to do this.
    The nib I use has no File's Owner and only contains a Navigation Controller that is configured to use my CustomNavigationBar and has no viewControllers

    In this case I set this up in code like this:

    // Load my nib with only a Navigation Controller and custom navigationBar
    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomNavigationController" owner:nil options:nil];
    
    // The only top level object will be my navigationController
    UINavigationController *navigationController = [topLevelObjects objectAtIndex:0];
    
    // Push a view controller to be the rootViewController
    [navigationController pushViewController:rootViewController animated:NO];
    

    Then present this controller however I normally would. The controller/window that presents it will take the required retain on the UINavigationController

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have UINavigationBar subclassed and I add a custom background like so: @implementation CustomUINavigationBar
I have the following loop in my viewDidLoad: for(int i=1; i<[eventsArray count]; i++) {
I have a UITableView with the following code: - (void)viewDidLoad { [super viewDidLoad]; parser
I have a simple mapview that has the following viewdidload method and didupdate to
I have a UITableViewController. In viewDidLoad I set the rowHeight: self.tableView.rowHeight = 43; But
I have the following code in my viewDidLoad to change an image: - (void)viewDidLoad
In viewDidLoad I have the following added to the subview: NSArray *pa = [NSArray
In a simple UITableView I have: - (void)viewDidLoad { NSArray *array = [[NSArray alloc]initWithObjects:@Pictures,@Video,@Text,@Map,nil];
Consider the following code in my TTTableViewController , I have - (void) viewDidLoad {
In the .m file of my ViewDidLoad I have the following code: if (![@1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.