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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:04:56+00:00 2026-06-17T22:04:56+00:00

This is bugging the heck out of me! I’m just trying to programmatically add

  • 0

This is bugging the heck out of me! I’m just trying to programmatically add a right-side “flash” button to my navigation bar, and for whatever reason, I can’t make it appear. My code is below. Can anyone help me? Thanks in advance.

 //Note: flashButton is declared as a UIButton property in .h, and synthesized in .m        
    UIView *flashContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 36, 36)];

    [flashButton addTarget:self action:@selector(toggleTorch) forControlEvents:UIControlEventTouchUpInside];
    [flashButton setBackgroundImage: [UIImage imageNamed:@"FlashIconInactive_small.png"] forState:UIControlStateNormal];
    [flashButton setBackgroundImage: [UIImage imageNamed:@"FlashIconActive_small.png"] forState:UIControlStateHighlighted];

    [flashContainer addSubview:flashButton];
    [flashButton sizeToFit];

    UIBarButtonItem *flashButtonItem = [[UIBarButtonItem alloc] initWithCustomView:flashContainer];

    scannerVC.delegate = self;
    scannerVC.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelTapped)];
    [[scannerVC navigationItem] setRightBarButtonItem:flashButtonItem];
  • 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-17T22:04:57+00:00Added an answer on June 17, 2026 at 10:04 pm

    Is flashButton connected to a button in a xib or storyboard via an IBOutlet? If not, you’ll need to create an instance of UIButton using +[UIButton buttonWithType:].

    Another test to try is to set a breakpoint on your first line (the addTarget: one) and enter po flashButton in the debugger. What’s the output? If it’s nil, then your button doesn’t exist and needs to be created.

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

Sidebar

Related Questions

I know this may be a noob question, but it's bugging the heck out
Ok, this is bugging me, and I just can't figure out what is wrong...
this is bugging me for a week already. Well I just badly needed to
This has been bugging me for a couple days. I'm trying to load a
This has been bugging me for a good hour. I'm starting out with Telerik
This has been bugging me for years, but I've just been ignoring it, like
This is bugging me for over 2 hours now, and I just don't see
This has been bugging me for days; I'm trying to send a SOAP post
This has been bugging me today after checking the source out on a site.
This is really bugging me and I can't figure it out. I have a

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.