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 8961359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:52:23+00:00 2026-06-15T15:52:23+00:00

In my RootViewController, I set an image as a rightBarButtonItem exactly like this, but

  • 0

In my RootViewController, I set an image as a rightBarButtonItem exactly like this, but in this second ViewController I created, this “back” button won’t display. I run it on the simulator and on my iPhone and I can tap the area where the button should be showing up and the goBack{} method is being called. Just the image(s) aren’t showing. Any thoughts?

Also, as far as the images go, I’m exporting them the exact same way I’ve been exporting all my other images. All the others have been working fine. It doesn’t seem like a problem with the images, as I’ve substituted the back button images for several others and none of them are displaying. I’m pretty sure I’m creating these images in the right order. Anyway, any help would be much appreciated.

From my NewGameViewController.m file:

- (void)viewDidLoad {
    [super viewDidLoad];

    CGFloat startingPoint = 0.0;
    CGRect bounds = self.view.bounds;
    bounds.origin.y = startingPoint;
    bounds.size.height -= startingPoint;

    self.ivarNewGameTableView = [[UITableView alloc] initWithFrame:bounds style:UITableViewStyleGrouped];
    self.ivarNewGameTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.ivarNewGameTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self.view addSubview:self.ivarNewGameTableView];

    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
    self.ivarNewGameTableView.backgroundView = backgroundImageView;

    UIImage *mainNavBar = [UIImage imageNamed:@"startNewGameNavBar.png"];
    UIImageView *navBarView = [[UIImageView alloc] initWithImage:mainNavBar];
    [navBarView setFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
    [self.navigationController.navigationBar addSubview:navBarView];

    UIButton *back = [UIButton buttonWithType:UIButtonTypeCustom];

    // neither one of the following lines work.  I know they're supposed to be identical, but
    // seen Xcode be picky.
    back.frame = CGRectMake(0.0, 0.0, 54.0, 36.0);
//    [back setFrame:CGRectMake(0.0, 0.0, 54.0, 36.0)];

    [back addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    [back setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
    [back setImage:[UIImage imageNamed:@"backTouched.png"] forState:UIControlStateHighlighted];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:back];
    self.navigationItem.leftBarButtonItem = backButton;
}

-(void)goBack {
    NSLog(@"goBack called.");
//    [self.ivarNewGameTableView pushViewController:];
}
  • 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-06-15T15:52:24+00:00Added an answer on June 15, 2026 at 3:52 pm

    Ok. Finally figured this out. The problem was with this line in the creation of my New Game View Navigation Bar:

    [self.navigationController.navigationBar addSubview:navBarView];
    

    I did this in my Root View’s Navigation Bar too. It now looks like this, in both files:

    UIImage *startNewGameNavBar = [UIImage imageNamed:@"startNewGameNavBar.png"];
    
    // with the key line being this one
    [self.navigationController.navigationBar setBackgroundImage:startNewGameNavBar forBarMetrics:UIBarMetricsDefault];
    

    In noob-speak, as I wish more programmers would use for noobs like me, if you’re having problems with buttons disappearing behind the your custom navigation bar, and you’re using code that looks like my example, it’s because you’re not supposed to be adding it as a subview. This puts it on top of everything else. Instead, change the navigation bar’s background image and, of course, the image winds up in the…(drumroll, please)…background. (end drumroll)

    As for the adding of the button images, I just created a UIButton with custom type, set the images for the normal and highlighted states, set the button to call my goBack method, set its frame size, and assigned it to the navigationItem’s leftBarButtonItem property:

    UIButton *backButton =  [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
    [backButton setImage:[UIImage imageNamed:@"backTouched.png"] forState:UIControlStateHighlighted];
    [backButton addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    [backButton setFrame:CGRectMake(0.0, 0.0, 54.0, 36.0)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can set self.navigationItem.backBarButtonItem of my RootViewController , so that the back button is
I created UITabBarController with each tab contain UINavigationController and set rootviewcontroller in this UINavigationController
Is this a good way to set a custom ViewController as the rootViewController of
I have this button on the leftside of my UISplitViewController (RootViewController) that has a
So I created a UINavigationController manually, set it as my UIWindow's rootViewController, and I
I have a login screen set up from the app delegate like this: NSUserDefaults
i have more viewcontroller that start from rootviewcontroller. So for example i start with
I've been pretty good at fixing my Xcode Obj-C errors, but this one has
So, my app is a set of stacked views, with a RootViewController as the
I created an application with a side menu like facebooks. I have a root

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.