【发布时间】:2013-01-29 15:59:16
【问题描述】:
我有一个 UITableViewCell 子类,打开自动布局后,我现在收到此错误:
2013-01-29 15:46:15.555 iP2[6690:907] *** Assertion failure in -[MenuTableViewCell layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2372/UIView.m:5776
2013-01-29 15:46:30.357 iP2[6690:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. MenuTableViewCell's implementation of -layoutSubviews needs to call super.'
MenuTableViewCell 是我的子类。
我猜这与 IB 如何决定自动构建此单元格的约束有关。这是我为此单元设置 IB 的屏幕截图:https://www.evernote.com/shard/s4/sh/0ec12042-7d37-4770-8d7a-c0c8c1e4e6f0/3192e32e8fde55dfe94c7269c428f73b
【问题讨论】:
-
你在子类中覆盖 layoutSubviews 吗?
-
没有。所以我假设 UITableViewCell 是,这可能不是调用 super.
-
当你调用 addSubview 调用 layoutSubviews [tableCell addSubview:viewFromXib]; [tableCell layoutSubviews];
标签: objective-c uitableview interface-builder autolayout