How do I attach an action to a button using Interf

2019-07-29 07:47发布

问题:

I am new to Interface Builder. I have a method (IBAction) defined in my class. I want to fire this method when a particular button is clicked.

I cant see any way to add an action via the IBBuilder

回答1:

Setting up an Action

  1. Right-Click on your control instance
  2. Drag to your target and let go.


Setting up an Outlet

  1. Right-Click on your object instance
  2. Drag to your control instance and let go.


Inspecting Actions/Outlets/Bindings

  1. Right-Click on your object instance



回答2:

Have you defined your method as an IBAction? You need to do like this for the method appear in the "File Owner's".