【问题标题】:IB Designables for storyboard UITableViewCell: Failed to render and update auto layout status for CountdownViewController The agent crashed [duplicate]故事板 UITableViewCell 的 IB Designables:无法渲染和更新 CountdownViewController 的自动布局状态代理崩溃 [重复]
【发布时间】:2018-05-11 03:32:28
【问题描述】:

好像我用错了@IBDesignbale,但是为什么呢?

我想使用IBDesignableprepareForInterfaceBuilder 的组合将一些数据注入到我的MyTableViewCell 中,这样它就可以在我的故事板中显示一些虚拟数据(在这个示例项目中,只需设置dummyView.backgroundColor = .red )。

我目前的设置:

1,我猜是使用情节提要的 tableview 的通常设置。视图中的 TableView 并将UITableViewCell 拖到 tableview 中。

2,标记我的MyTableViewCell@IBDesignable

3、覆盖MyTableViewCell内的prepareForInterfaceBuilder设置dummyView backgroundColor

错误:

Main.storyboard:错误:IB Designables:无法渲染和更新 ViewController (BYZ-38-t0r) 的自动布局状态:代理崩溃

【问题讨论】:

    标签: ios uitableview ibdesignable


    【解决方案1】:

    发生这种情况是因为您的 dummyViewIBOutlet 并且被隐式解包。 prepareForInterfaceBuilder 将在 dummyView 初始化之前被调用。您可以通过将代码更改为dummyView?.backgroundColor = .red 来防止崩溃,但由于dummyView == nil,因此不会呈现任何内容。

    IBDesignableIBOutlet 混合使用没有多大意义。通常,IBDesignable 旨在使运行时布局和绘图在设计时可见。但是IBOutlets 在设计时必然已经可见。然而,这在 xib 中可能是可取的。有关该问题的讨论,请参阅 herehere.

    【讨论】:

      猜你喜欢
      • 2020-06-29
      • 2017-02-05
      • 1970-01-01
      • 2018-03-25
      • 1970-01-01
      • 2019-11-17
      • 2015-02-07
      • 1970-01-01
      相关资源
      最近更新 更多