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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:13:27+00:00 2026-05-24T19:13:27+00:00

Ive put in a custom Back UIBarButtonItem, which is from an Image i made

  • 0

Ive put in a custom “Back” UIBarButtonItem, which is from an Image i made in photoshop. Ive managed to make it appear just fine, my problem is making it work.

My button does nothing, im assuming because i havent assigned any actions to it. I just dont know the correct syntax to do so?

Heres my code

    UIImage *buttonImage = [UIImage imageNamed:@"BackButton.png"];
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [backButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
        backButton.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);

// Im assuming this is where i need to put the action...
        //[backButton addTarget:self action:@selector(.......) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] 
                                                 initWithCustomView:backButton];

Basically, i want my new custom backbutton to function just like the default one in a regular UITableView

regards,
Andyy

  • 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-24T19:13:28+00:00Added an answer on May 24, 2026 at 7:13 pm

    You can do this in IB or you can do it in code with a call to addTarget:action:forControlEvents: for UIControlEventTouchUpInside to invoke a method (action) when the button is tapped. For example:

    [backButton addTarget:self action:@selector(backButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    

    This is documented in UIControl class reference, UIButton is a subclass of UIControl.

    You’ll need a method which will be called when the event occurs, which I called backButtonPressed: in my code above. This method takes one parameter, the object sending the event, something like this:

    -(void)backButtonPressed:(id)sender
    {
        // NOTE: assumes self is your UIViewController
        [self.navigationController popViewControllerAnimated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a custom report. I've just put some test code on
I've got a UIButton (custom, with image) set up in IB which is an
I have a custom configuration page in my app which just so happens to
Ive given my wordpress user a custom field in the backend which is a
I've got some custom metadata to put into a PNG file. It's being saved
I'm using Smarty templates which call object methods. I've put the code on a
I'm trying to set up log4net but I cannot make it work. I've put
I'm trying to make a custom theme for a drupal blog, and I want
I wanted to make custom social buttons (with Like links to Facebook, share links
I've put some images next to NSMenuItems using the image option in Interface Builder.

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.