将操作连接到Xcode中的按钮

Ama*_*H-V 15 xcode objective-c interface-builder

如何将Interface Builder中添加的按钮连接到操作?这是我将论坛组件添加到我的应用程序的说明.它说"将该按钮的动作连接到IB中的"launchSatisfactionRemoteComponent:"方法.这需要在我的"Support.xib"窗口中进行.将操作连接到的代码在哪里?

Rob*_*dan 27

在您的代码中,添加处理该操作的方法.例如,

.h文件

- (IBAction)buttonTapped:(UIButton *)sender;
Run Code Online (Sandbox Code Playgroud)

.m文件

- (IBAction)buttonTapped:(UIButton *)sender
{
  NSLog(@"Button Tapped!");
}
Run Code Online (Sandbox Code Playgroud)

现在,打开你的xib文件,右键单击File's Owner,你应该看到你的方法,将加号圈拖到你的按钮上.你应该看到一堆不同的动作,大多数时候touchUpInside就是你要找的东西.