views:

39

answers:

1

Is there a way to hookup a button click to a method programmatically? It would be like imitating the CTRL+CLICK in Interface Builder.

+3  A: 

Check out UIControl, what UIButton inherits from. Specifically this method:

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

The action is the method you want to be invoked, and controlEvents represents the events that the action method should be called for, e.g. UIControlEventTouchUpInside for a click.

Rob Jones