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.
精彩评论