CustomTableCellView的-layoutSubviews实现需要调用super,NSInternalInconsistencyException
在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
可以通过将所有内容放置在容器视图中的自定义tableview单元格中来解决iOS6问题。 即创build一个新的视图来填充单元格,然后将控件等放在里面。 还要确保你设置:
[theContainerView setTranslatesAutoresizingMaskIntoConstraints:NO];
为容器和子视图
iOS 5.1及更早版本与AutoLayout不兼容。 这只适用于iOS 6.0+。
假设你使用的是故事板,如果你想使用AutoLayout,但仍然保持6.0以前的iOS版本的兼容性,你需要创build两个目标:一个用于iOS 6,另一个用于iOS 5(或更早)。 对于每一个,设置一个单独的故事板,其中启用了AutoLayout(对于iOS 6),另一个不是(对于iOS 5)。
下面是一个使用AutoLayout实现最佳实践并向下兼容iOS 5的StackOverflow线程: 在iOS 6中启用自动布局,同时保持向后兼容iOS 5 。
根据我的经验,如果您需要向后兼容,则不值得使用AutoLayout。 如果你正在使用故事板,有2个目标和2个故事板同步是一个维修头痛。 如果您不使用故事板,则需要iOS 5和iOS 6的单独代码,这将需要更长的时间来testing和更新。
- UITextView contentInset无法在iOS 7上的UITextView中工作?
- 滚动查看与embedded式tableview
- iOS检查火炬是否开启
- iOS测试的一些有用的提示和技巧
- 在Swift中创建不可变的委托
- NSInternalInconsistencyException:'无效的参数不满意:!stayUp || CLClientIsBackgroundable(内部- > fClient)”
- 每次打开iOS应用程序时都被迫创build一个新的Quickblox会话
- 在iOS应用程序中使用swift下拉菜单
- GoogleToolboxForMac.framework和GoogleOpenSource.framework冲突