Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
i understand it's not typical to connect/call only one method for different control events, but i would like to know if it's even possible.

example: a button targets a method, but the method executes different code depending on if the button is being pressed or being released.

Code:
- (IBAction)buttonAction
{
if (UIControlEvent == UIControlEvenTouchDown) NSLog(@"button pushed");
if (UIControlEvent == UIControlEventTouchUpInside) NSLog(@"button released");
}
 
Certainly possible. Connect different IBActions to different events. Look at all the events that are available for button connections:
 

Attachments

  • Screen shot 2010-01-24 at 11.22.41 AM.png
    Screen shot 2010-01-24 at 11.22.41 AM.png
    32.5 KB · Views: 145
Certainly possible. Connect different IBActions to different events. Look at all the events that are available for button connections:

right. however, i'd like to connect the control events to one method, and manage them thru this one method. actually, i'd like to know if it's possible rather than actually do it. is it possible?
 
however, i'd like to connect the control events to one method, and manage them thru this one method. actually, i'd like to know if it's possible rather than actually do it. is it possible?
It's certainly possible to connect different events to the same IBAction method. Whether you can manage them from within that method, I'm not sure. If you are just going to logically separate them within the method though, why not just use separate IBActions to start with?
 
I've been playing around with Apple's TaggedLocations (think that's the right name) and trying to use the tag property to do this (set the tag value of each control in IB, then check it in the action). I think this is the way to go, but the TaggedLocations code is a little unusual, and is preventing this from working by the way they use delegation....
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.