Reputation: 75
Im sure this is probably a very noob question and I apologize in advanced...
This is the first time I have ever created a UIButton programmatically, usually I do it through story board, which easily allows me to connect the button to an action. so my question is, how would I go about connecting this button to an action? (Programmatically of course).
Thanks.
Upvotes: 0
Views: 153
Reputation: 4551
[myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]
buttonClicked:
is the method that runs when to button is pushed. So if you don't have a method for that you need to create it.
Like this:
- (IBAction) buttonClicked: (id)sender {
NSLog(@"Button pressed");
}
Upvotes: 3