IBOutlet instances are (null) after loading from NIB

前端 未结 5 1876
太阳男子
太阳男子 2021-02-18 22:30

I am working on an iPhone app and am getting (null) references to IBOutlet fields in my controller. I have a UIViewController subclass that is set as the File\'s Owner in my XIB

5条回答
  •  青春惊慌失措
    2021-02-18 22:42

    I guess asking the question after looking at the problem for over an hour led me to figure it out:

    I just changed my code to check the text box AFTER displaying the view... now everything is instantiated.

    Imagine that: the UI elements aren't instantiated until you display them!

提交回复
热议问题