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

  • Home
  • SEARCH
  • 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 6215147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:00:07+00:00 2026-05-24T07:00:07+00:00

What I want to do is a navigation bar with a image on it.

  • 0

What I want to do is a navigation bar with a image on it. I have a tab controller on my main view, and inside each tab I have a UINavigationController. From inside the UIViewController that my tab/navigationController calls, I could set the titleView without much problem, doing this inside the viewDidLoad method:

self.navigationItem.titleView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mylogo.png"]] autorelease];

But, I want to replace all titles in my navigationBar for this view, and it seems ugly to repeat this everywhere. So I did this on the delegate (after linking all the Outlet stuff)

self.tabOneNavController.navigationBar.topItem.titleView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mylogo.png"]] autorelease];

Again, it worked! ok, I’m almost getting there.
But the point is, I’ve 5 tabs and all of them have navigationControllers inside. I reduced the code repetition from every internal view to only 5 times, but it still. It requires that I do that for the NavController of each tab.

Then I tried to extend the UINavigationBar to create my own, where I could set this in the initializer, and use it in the interface builder as the object class. But it doesn’t seem to work. Here is what I did:

@implementation MyNavigationBar

- (id)init {
    self = [super self];

    self.tintColor = [UIColor greenColor];
    self.topItem.title = @"testing please work";

    return self;
}

@end

in the interface file MyNavigationBar inherits from UINavigationBar. But this didn’t work. Should I overwrite other method? which one? is this a good practice?
I’m not even sure if I should add one navigationBar for each tab, as I said, I have tabs and I want to have a navigation bar / navigate inside them. By now, after a near death experience trying to figure out how the interface builder / outlets and classes work, the code is working, I just would like to make unglify it.

Thank you!

  • 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-24T07:00:09+00:00Added an answer on May 24, 2026 at 7:00 am

    The problem of repeating code which you describe has an elegant solution. Objective-C supports something called a “category”, which allows you to add methods to a class. A common use for this is to customize navigation and tab bars. In Xcode 4, you would do something like this to add a category on UINavigationBar:

    Hit Command+N or open the “New File” dialog. Next, choose “Objective-C category” from the Cocoa Touch menu:

    Creating a category

    Click Next and you will be prompted to enter the name of the class that you would like to add methods to as a category. It should look something like this:

    Making a Category on the NavBar

    Then, you should end up with a save file dialog. A quick note about convention here. Convention is to name a category after the original class, the plus sign, and then a description of what you’re adding. Here’s what yours might look like:

    Category Naming Convention

    Once you save your file, you will need get something like this:

    Empty Category

    Look at that beauty. You can now override the default drawing/init methods as well as extend the functionality of the navbar.

    I’d suggest looking into the init and drawRect methods, although I don’t remember which ones people use. Also, please note that while under NDA, this may change in iOS 5, so just be prepared for that possibility.

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

Sidebar

Related Questions

I have a Tab Bar controller inside a Navigation controller. I want to create
I have a navigation bar that I want to get the width of each
I have a navigation controller which also has a table view. I want to
I have a navigation controller and when I place an image for navigation bar
i have 3 navigation controller and i want to change each background using different
In my iphone application, I have a one navigation bar Image to set I
I want to display the image in navigation bar instead of a back button
how can i set an image into the background of the navigation-bar, so that
I am working on iPhone app. I have added Navigation bar Background image With
I have a navigation based application. I want to add an image covering the

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.