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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:09:16+00:00 2026-05-26T21:09:16+00:00

I am using an UIBarButtonItem in order to trigger events. I use the integrated

  • 0

I am using an UIBarButtonItem in order to trigger events. I use the integrated InterfaceBuider in xcode4 to create my UIBarButtonItem and then I connected the button to a method in my view controller. The method looks like this:

-(IBAction)NoteOnOff:(id)sender
{
    UIButton *button = (UIButton*)sender;

   /* now perform action */
}

Now I want to also detect fingerdown/fingerup because I want to trigger noteon/noteoff types of event for a midi synth kind of app.

1- Is there a way to detect if sender has been pressed down or up in the above method?

2- I tried to subclass UIBarButtonItem and implement touchesBegan and touchesEnded this way:

@interface myUIBarButtonItem : UIBarButtonItem {

}

@end

@implementation myUIBarButtonItem

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesBegan");
NSLog(@"touches=%@,event=%@",touches,event);
}

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesEnded");
NSLog(@"touches=%@,event=%@",touches,event);
}

@end

Then I changed the class of the UIBarButtonItem to myUIBarButtonItem in the interface editor but no luck. Is that the correct way of using my customized class in the interface editor?

3- I read somewhere that UIBarButtonItem does not inherit from UIResponder so they can’t intercept touchesbegan/touchesended events. If that is the case then what is the proper way to be able to detect touches down and touches up events? I am mostly a C/C++ programmer and my knowledge is pretty limited about objective C and the iphone environement. I only know how to use the UI editor and I do not know how create custom UIs and use them without this editor yet.

Bottom line is: what is the simplest way to detect touchdown/touchup with the lest latency possible?

Any pointers to tutorial or docs is also welcome.

Thanks,

Baba

  • 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-26T21:09:17+00:00Added an answer on May 26, 2026 at 9:09 pm

    You can do it like this (no need to subclass UIBarButtonItem):

    [button addTarget:self action:@selector(touchUp:)
      forControlEvents:UIControlEventTouchUpInside];
    
    [button addTarget:self action:@selector(touchDown:)
      forControlEvents:UIControlEventTouchDown];
    
    - (void) touchUp:(id)sender {
    }
    
    - (void) touchDown:(id)sender {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create UIBarButtonItem using UIBarButtonItem *previous = [[UIBarButtonItem alloc] initWithTitle:@Search style:UIBarButtonItemStyleBordered target:self action:@selector(SearchAction:)]; how
I'm using the following code to create a custom edit button item: UIButton *editButton
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
I'm trying to display a small refresh button using UIButton in a standard UIView
In an iPhone app,we can make a UIBarButtonItem by using the following code: UIBarButtonItem
Using a split view on the iPad, I have the following code: - (void)
I've created a UIBarButtonItem and then set self.navigationItem.rightBarButtonItem to the item. However, setting the
I am currently using the following code in the AppDelegate to make a UIBarButtonItem
I'm using the following code to push a view controller when user click on

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.