在 tableView xib 的自定义单元格中使用 autoLayout 时,出现以下错误。
在 iOS 6 模拟器中运行时 CustomCells实现-layoutSubviews需要调用super
Assertion failure in
-[CustomCells layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. CustomCells's implementation of -layoutSubviews needs to call super.'
*** First throw call stack:
在 iOS 5 模拟器中运行时
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The NIB data is invalid.'
*** First throw call stack:
临时修复:
如果我在自定义单元格中禁用 autoLayout,它工作正常。 但是在这种情况下方向处理并不好。请帮忙。
最佳答案
layoutSubviews needs to call super
可以在 iOS6 上通过将所有内容放在容器 View 中的自定义 tableview 单元格中来解决。即创建一个新 View 来填充单元格,然后在其中放置控件等。还要确保设置:
[theContainerView setTranslatesAutoresizingMaskIntoConstraints:NO];
对于容器和 subview
关于iphone - CustomTableCellView的实现-layoutSubviews需要调用super,NSInternalInconsistencyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13627452/