Jonathan Starr
Jonathan Starr

Reputation: 254

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.

Upvotes: 0

Views: 392

Answers (1)

Chris
Chris

Reputation: 484

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.

Upvotes: 1

Related Questions