Can't connect IBOutlet in Interface Builder

前端 未结 19 2041
别跟我提以往
别跟我提以往 2020-12-04 20:02

I\'m having a weird experience. I create any type of iPhone application, add a UIViewController with Xib file. I can edit the xib file with controls and see them rendered if

相关标签:
19条回答
  • 2020-12-04 20:11

    Are you sure the File's Owner is correctly set to your custom UIViewController and that you've saved your .h file after having added the IBOutlet keyword to the instance variable and property?

    0 讨论(0)
  • Had the same problem.

    Fixed it by double checking my File's Owner "Class" attribute on the Identity inspector.

    0 讨论(0)
  • 2020-12-04 20:18

    I was having trouble here too, and what ended up working for me was to build the app prior to opening Interface Builder. Voodoo!

    0 讨论(0)
  • 2020-12-04 20:19

    I did a combination of the things in this thread and I finally had success.

    In Interface builder (not xcode)

    1. File->Reload All Class Files
    2. File->Read Class Files (select MyClass.h)
    3. Reconnect File's Owner by
      a. Setting the Class to "MyClass"
      b. Reconnecting the View to the File's Owner's View

    Everything is back to normal now. Weird.

    Hope this helps more than it confuses ;-)

    0 讨论(0)
  • 2020-12-04 20:20

    Did you make sure you are defining your outlets in your .h file as the appropriate type? If you are trying to connect a text field in IB, then your .h file should look something like...

    IBOutlet UITextField    *MyTextField;
    

    Make sure the type is UITextField (or UITextView, etc). If you type them as NSString or anything the is not appropriate, then you can't connect them in Interface Builder....

    0 讨论(0)
  • 2020-12-04 20:21

    I had the same problem for the LONGEST. Changing my File's Owner "Type" to "MyClassViewController" instead of "UIViewController" in the Class identity window fixed my issue. It makes sense because as the File's owner type is UIViewController it's only going to show those properties specific to the base class. Changing the type to MyClassViewController gives access to it's outlets and all inherited instances. Hope this helps!

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