Connecting actions to buttons in Xcode
How do I connect a button added in Interface Builder to an action? This is what my instructions for adding a forum component in to my app.开发者_开发问答 It says "Connect the action of that button to your "launchSatisfactionRemoteComponent:" method in IB." This would need to happen in my "Support.xib" window. Where is the code where you connect the action to that?
In your code, add the method to handle that action. For instance,
.h file
- (IBAction)buttonTapped:(UIButton *)sender;
.m file
- (IBAction)buttonTapped:(UIButton *)sender
{
NSLog(@"Button Tapped!");
}
Now, open you xib file, right click to File's Owner, there you should see your method, drag the plus circle onto your button. You should see a bunch of different actions, most of the time touchUpInside is what you are looking for.
精彩评论