tags:

views:

113

answers:

3

how to find that my button's event is Touch Down

i want to do function like this

if(users click on touchdown event) {

NSLog(@"a");

}

else if(users click on touchupinside event) {

NSLog(@"b"); }

A: 

You "find out" by letting the button tell you when the event happens.

Add a method (or methods) like this:

- (IBAction)myButtonClick:(id)sender;

In Interface Builder, attach the method(s) to the events you're interested in.

You create a separate method for each type of event if you want different behavior for a TouchDown as opposed to TouchUpInside.

DyingCactus
+1  A: 

Eather you set two different IBAction methods in the InterfaceBuilder or you set two different targets via:

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents

in your code while creating the button.

AlexVogel
A: 

you attach each unique event to its own IBAction

Tomen