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

后端 未结 3 1022
囚心锁ツ
囚心锁ツ 2020-12-17 23:09

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

3条回答
  •  悲哀的现实
    2020-12-17 23:47

    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.

提交回复
热议问题