将.xib中的对象连接到现有IBAction [英] Connect object in .xib to existing IBAction
问题描述
我对iOS编程很陌生。
I am quite new to iOS Programming.
这是我的问题:
我想连接现有IBAction方法的新对象。例如,我想按钮执行相同的功能。
I want to connect a new object to an existing IBAction method. For example, I want to buttons to perform the same function.
但是当我控制 - 拖动它时,它总是要求我插入一个新方法。如何添加到现有的?而不是创建新的?
But when I "control-drag" it, it will always ask me to insert as a new method. How can I add to the existing one instead of creating a new one?
XCode中的快照
Snapshot in XCode
推荐答案
在 xib中
编辑器,你可以看到文件的所有者
。只需右键单击按钮即可看到黑色弹出窗口,如下图所示。然后将空点拖到文件的所有者
标签中,然后释放拖动操作。您将看到所有现有 IBAction
的弹出窗口。选择您想要的那个,它将作为选择器添加到您的按钮。您可以根据需要为多个按钮执行此操作。
In your xib
editor, you can see the File's Owner
. Just right click the button to see the black popup as shown in the image below. Then drag the empty dot to the File's Owner
tab and release the drag action. You'll see a popup of all existing IBAction
s. Select the one you want and it'll be added as a selector to your button. You can do this for as many buttons as you want.
这篇关于将.xib中的对象连接到现有IBAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!