Xcode 4: Creating a UIView xib, not properly connecting

前端 未结 30 3432
时光说笑
时光说笑 2020-12-02 16:29

I\'m trying to create a nib that contains a view that will be embedded in a TableViewCell. I\'ve created the interface and implementation files, ResultCell.h an

相关标签:
30条回答
  • 2020-12-02 17:08

    I encountered the same problem today. Restarting XCode did not fix the problem for me. I was able to get things back to normal by using "Delete" option of "Derived Data" of the project that can be found under Organizer. Organizer says that, "Derived Data includes index, build output and logs". I guess that either index or build output was causing this issue.

    0 讨论(0)
  • 2020-12-02 17:08

    The new class not being part of the "TARGET" is likely the root cause of this, as alluded to by some of these answers.

    When creating a new cocoa class, by default the option to add new class to target is by default checked, but should, for any reason, this not be checked when you hit save, you will have this issue.

    New Class Target

    Any of these workarounds that add the new class to the apps target will work to resolve the problem, and is something that all these 'fixes' have in common.

    I think XCode likely has some bugs that causes a new file to, by default, NOT be added to the apps main target. The fix boils down to adding your 'broken' class to the main TARGET

    0 讨论(0)
  • 2020-12-02 17:12

    This helped me out:

    1. from the project file Panel (left side) select the xib file that is broken.
    2. Click on the Files Owner icon from the editor view.
    3. from the properties Panel (right side) select the third tab (at the top)
    4. specify the "Custom Class"

    If you do not see a "panel", please have a look at the top-right corner of the window and enable the proper "view" buttons. If you don't see the "view" buttons then click on the top-right most capsule button.

    0 讨论(0)
  • 2020-12-02 17:12

    Renaming the class files may unlink them from the XIB. This answer helped me discover this:

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

    Check that your custom class is set correctly in the Identity Inspector.

    0 讨论(0)
  • 2020-12-02 17:12

    For me wether cleaning nor deleting the DerivedData solved the problem.

    I tried to delete and recreate my UIViewController class several times and got the problem again and again.

    Then I recreated the UIViewController class and gave it a different name. This solved the problem for me.

    0 讨论(0)
  • 2020-12-02 17:13

    In my case it helped to make a "fake change" (just a space) to the according header file.

    0 讨论(0)
提交回复
热议问题