开发者

Connect touch event in ios

开发者_如何学编程

Now that I know that NSEvent does not exist on ios - what do I need to do to capture an event like touchUpInside and cause it to call my method to handle it, WITHOUT Interface Builder?

I think this like asking how do I link an event to an outlet without IB...

I know it can be done, but I can't find anything that shows how - except Mac-only examples that use NSEvent.


Take a look at this method in UIControl:

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

Each of the different event types has a constant, such as UIControlEventTouchUpInside. Here's an example of it being used:

[addButton addTarget:self action:@selector(increment:) forControlEvents:UIControlEventTouchDown];

Look here for the values of controlEvents, listed in the Constants section.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜