views:

33

answers:

2

Is there a similar method in xcode to the AS3 "AddEventListener" code?

I want to be able to watch for a certain thing to happen, but not use up too much memory.

Basically I have 8 buttons. Obviously I can't just go through a for loop to see if a touch is on them, I need an event or a trigger or something.

(The reason I don't just use normal buttons is that I need to be able to slide onto them.)

Any ideas?

A: 
[yourButton addTarget:self action:@selector(clickHandler:) forControlEvents:UIControlEventTouchUpInside];

-(void)clickHandler:(id)sender{
  //your actions
}
Jorge
I would use that, but the problem is I need to be able to track draging into the button as well. I need more of a check for whether or not a touch is inside the bounds of a button.
XenElement
A: 

I assume you are implying you are using UIView and not UIButton. What you are looking for is a UIGestureRecognizer, which you would attach to the view. Review the SimpleGestureRecognizers sample project for examples of how to accomplish this.

Seems to be what I was looking for! Thanks!
XenElement