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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:11:22+00:00 2026-05-27T10:11:22+00:00

So I’m adding a bunch of custom UIBarButtonItems to a UIToolbar, and they all

  • 0

So I’m adding a bunch of custom UIBarButtonItems to a UIToolbar, and they all load just fine and look great, and I can see them in my UIToolbar. The only problem is, I can’t perform any actions on them. In my viewDidLoad, I set up everything. Here are my .h and .m files:

.h file:

#import <UIKit/UIKit.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import <QuartzCore/QuartzCore.h>

@interface PhotoEditViewController : UIViewController <UIPopoverControllerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIGestureRecognizerDelegate> {
    IBOutlet UIImageView *imageView; 
}

- (IBAction)cancelEdit:(id)sender;
- (IBAction)savePhoto:(id)sender;
- (IBAction)chooseColor:(id)sender;


@property (retain) IBOutlet UIToolbar *editBar;
@property (retain) UIImageView *imageView;
@property (retain) UIImage *tempImage;

- (void) setupStache;

@end

.m file: (viewDidLoad)

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.imageView.image = tempImage;


    NSMutableArray *toolbarItems = [NSMutableArray arrayWithCapacity:3];

    // get the filepaths of all the images
    NSString *imagePath_cancel = [[NSBundle mainBundle] pathForResource:@"barBtnPhotoEditCancel" ofType:@"png"];
    NSString *imagePath_save = [[NSBundle mainBundle] pathForResource:@"barBtnSavePhoto" ofType:@"png"];
    NSString *imagePath_color = [[NSBundle mainBundle] pathForResource:@"barBtnChangeColor" ofType:@"png"];


    // get the images
    UIImage *cancelImage = [[UIImage alloc] initWithContentsOfFile:imagePath_cancel];
    UIImage *saveImage = [[UIImage alloc] initWithContentsOfFile:imagePath_save];
    UIImage *changeColorImage = [[UIImage alloc] initWithContentsOfFile:imagePath_color];

    // set the images to the UIBarButtonItem(s)
    CGRect cancelFrame = CGRectMake(0, 0, cancelImage.size.width-25, cancelImage.size.height-25);
    UIButton* cancelButton = [[UIButton alloc] initWithFrame:cancelFrame];
    [cancelButton setBackgroundImage:cancelImage forState:UIControlStateNormal];
    [cancelButton setShowsTouchWhenHighlighted:YES];
    UIBarButtonItem *cancelBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:cancelButton];
    [cancelBarButtonItem setTarget:self];
    [cancelBarButtonItem setAction:@selector(cancelEdit:)];


    CGRect saveFrame = CGRectMake(0, 0, saveImage.size.width-25, saveImage.size.height-25);
    UIButton* saveButton = [[UIButton alloc] initWithFrame:saveFrame];
    [saveButton setBackgroundImage:saveImage forState:UIControlStateNormal];
    [saveButton setShowsTouchWhenHighlighted:YES];
    UIBarButtonItem* saveBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:saveButton];
    [saveBarButtonItem setTarget:self];
    [saveBarButtonItem setAction:@selector(savePhoto:)];


    CGRect colorFrame = CGRectMake(0, 0, changeColorImage.size.width-25, changeColorImage.size.height-25);
    UIButton* colorButton = [[UIButton alloc] initWithFrame:colorFrame];
    [colorButton setBackgroundImage:changeColorImage forState:UIControlStateNormal];
    [colorButton setShowsTouchWhenHighlighted:YES];
    UIBarButtonItem* colorBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:colorButton];
    [colorBarButtonItem setTarget:self];
    [colorBarButtonItem setAction:@selector(chooseColor:)];


    // add all the items
    [toolbarItems addObject:cancelBarButtonItem];
    [toolbarItems addObject:saveBarButtonItem];
    [toolbarItems addObject:colorBarButtonItem];

    [self.editBar setItems:toolbarItems animated:NO];


    // release everything
    [cancelBarButtonItem release];
    [cancelButton release];
    [saveBarButtonItem release];
    [saveButton release];
    [colorBarButtonItem release];
    [colorButton release];
}

- (IBAction)cancelEdit:(id)sender {
    NSLog(@"Pressing the cancel button");
}

- (IBAction)savePhoto:(id)sender {
    NSLog(@"Pressing the save button");    
}

- (IBAction)chooseColor:(id)sender {
    NSLog(@"Pressing the choose color button");    
}
  • 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-27T10:11:23+00:00Added an answer on May 27, 2026 at 10:11 am

    So, here’s the answer.

    I was inserting a custom subview that was the size of the entire screen (320×640). It also had gestureRecognizers attached to it. Therefore, whenever I tapped that view, the gestureRecognizer responded to the attached subview, instead of the uitoolbar, or the buttons on it. Man I’m foolish. Resized the image on the UIView, and everything works fine. 🙂 Thanks everyone for the help.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an XML file, the creators of it stuck in a bunch social
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.