Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call action method for a uibutton without using interface builder in cocoa

I'm currently calling an action method in an object by dragging a button to the view in interface builder. I then drag an object to the panel and specify my object with the action method. I shift drag my button to the object and choose my action method. This works in calling my method.

I would like to instead call my action method without interface builder from uiview class that the current nib is derived from.

Does anyone know how I can accomplish this?

like image 564
Atma Avatar asked Dec 03 '22 14:12

Atma


1 Answers

I read the question differently than Jasarien from the first answer.

If you are trying to get a button to respond to a click, but you want to setup the selected target method without using IB, it would go like this.

[myButton addTarget:self action:@selector(myMethod:) forControlEvents:UIControlEventTouchUpInside];
like image 76
NWCoder Avatar answered Jan 11 '23 22:01

NWCoder