Xcode - Equivalent to Actionscript 3 event listener
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 ha开发者_高级运维ve 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?
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.
[yourButton addTarget:self action:@selector(clickHandler:) forControlEvents:UIControlEventTouchUpInside];
-(void)clickHandler:(id)sender{
//your actions
}
精彩评论