How do I attach an action to a button using Interface Builder?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 12:09:54

问题


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".



来源:https://stackoverflow.com/questions/6319212/how-do-i-attach-an-action-to-a-button-using-interface-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!