开发者

Xcode - Equivalent to Actionscript 3 event listener

开发者 https://www.devze.com 2023-01-20 03:34 出处:网络
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.

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消