Endless recursive calls to initWithCoder when instantiating xib in storyboard

扶醉桌前 提交于 2019-12-01 05:46:07

Did you happen to set the View's "Custom Class" in your .xib file to "Widget"?

That would explain the behaviour you're seeing, because initWithCoder: is the initializer for all things loaded from a xib:

  1. Your parent view, which contains a Widget object, is loaded from the xib
  2. The Widget's initWithCoder: method gets called, and tries to load the Widget xib
  3. The Widget xib contains a UIView with the Custom Class "Widget", so again, a Widget object is being initialized with initWithCoder:, etc.

If that is indeed the case, all you have to do is remove the "Custom Class" entry for the UIView in your Widget's xib.

I had same problem. My mistake was in empty File's Owner class. In File's Owner custom class must be NOT empty (Widget), and root view must be empty.

IBActions and IBOutlets were fine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!