Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
663 views
in Technique[技术] by (71.8m points)

objective c - Ctrl-Drag from button to method not working. Xcode/Interface Builder

I am building an iOS app and i have most of the code/GUI built (its a single view app). Now i have the .xib and controller.h file next to each other and I want to associate a button click with a certain action. Everytime I try nothing happens. The UI indictor that I am dragging shows up but it wont let me connect to the method. This happens for all the objects/methods.

I have an almost identical project that works just fine too!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Select your XIB file and then select "Files Owner" which is the yellow cube. In the Utilities Sidebar, select the Icon with the circle and arrow inside of it (which is the "Connections Inspector"). You can then Control + Drag your to your button.

//// Edit ////

After investigating your project... Pretty sure you deleted a storyboard and then added a .xib but didn't set it's class, or link it's view as an outlet.

To do that:

  1. Select the new view (XIB), then selct the main view, and in the identity inspector, set it's class to your custom class name "AVYSViewController."

  2. Switch to the connections inspector and Control + Drag the "view" outlet to the main view in your XIB.

Also, your project was looking for the MainStoryBoard.storyboard file. So get rid of that setting by selecting your project, then selecting your target, and in the "Summary" tab, delete anything in the "Main Storyboard" field.

Note: I checked to see if your project settings were valid before I deleted the storyboard setting and it returned NO errors, so beware of this problem for future projects.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...