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

The Archive Base Latest Questions

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

I have looked around quite a bit and can’t seem to get working a

  • 0

I have looked around quite a bit and can’t seem to get working a custom image in my toolbar. I have the code below in the custom initialization section of my ViewController.m, is this the correct place to add this? I don’t see any image show in the upper toolbar. I would like to place this on the right hand upper side of the view.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
    UIImage *image = [UIImage imageNamed:@"camera_30_30.png"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:image forState:UIControlStateNormal];

    button.frame = CGRectMake( 0, 0, image.size.width, image.size.height);
    button.showsTouchWhenHighlighted = YES;

    [button addTarget:self action:@selector(myAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

    NSMutableArray *items = [[NSMutableArray alloc] init];
    [items addObject:barButtonItem];
    self.toolbarItems = items;
}
return self;
}

Thanks for looking.

  • 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-11T02:52:17+00:00Added an answer on June 11, 2026 at 2:52 am

    This may be related to when you assign the toolbarItems. I assume this will need to be set inside the viewDidLoad method once the UI has been loaded.

    You could probably also simplify the bar button creation with this:

    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc]initWithImage:@"camera_30_30.png" style:UIBarButtonItemStyleBordered target:self action:@selector(myAction)];
    

    Also, in your code, you need to release items at the end

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

Sidebar

Related Questions

Sorry if this is obvious but have looked around and can't get this working:
I have looked around for quite some time trying to get openCV installed. I'm
Hope somebody can help. Have looked around on the net but cannot seem to
I've looked around and can't seem to quite find a solution that meets my
I have looked around but cannot seem to find anything quite like i need.
I have looked around quite abit and there does not seem to be any
I have looked around quite a bit, and nothing seems to answer my question
I've looked around and have bits and pieces but can't put the puzzle together.
Python beginner here. I've looked around and found similar questions but can't quite cobble
Hey guys, looked around but couldn't quite get an answer or figure it myself.

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.