How do I name and link an IBAction button created

2019-02-24 01:43发布

问题:

I named the button "Reminders"

Apparently it was supposed to link itself to the files but nothing showed up in mine.

I have created a button in the storyboard but I don't know how to link it to a .m or .h file.

I'm really new to this and still learning. Am I supposed to change the settings of the button and what code do I write in the files to make it work?

Thanks a heap!

回答1:

Here is how you add an IBOutlet to a header or a .m file:

  1. Open your storyboard editor on one window. Position it in such a way that the button is visible
  2. Open the header or the .m file in another window. Position the text in such a way so that the piece of code where you want the outlet added is visible
  3. Highlight the button in the storyboard, and hold the Control key down.
  4. Drag the button into the header or the .m file. You will see a blue line as you drag, and a blue marker where the outlet will be added.
  5. When the marker is at the place where you want it, release the mouse button. The outlet will be inserted and connected to the storyboard.

Here is a post that illustrates this process with a video.