-[UITableView layoutSublayersOfLayer:]中的断言失败 [英] Assertion failure in -[UITableView layoutSublayersOfLayer:]

查看:129
本文介绍了-[UITableView layoutSublayersOfLayer:]中的断言失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在UIViewController上使用UISearchDisplayController,其中包括UITableView.
我使用自动版式.当我尝试将SearchBar(_searchBar)放在tableHeaderView中时,

I want to use an UISearchDisplayController on UIViewController, that includes an UITableView.
I use Autolayout. When i try to put the SearchBar (_searchBar) in the tableHeaderView with

self.tableView.tableHeaderView = _searchBar;

我得到了错误 'NSInternalInconsistencyException',原因:'执行-layoutSubviews之后仍需要自动布局. UITableView的-layoutSubviews实现需要调用super.'

I get the error 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.'

禁用自动布局,错误消失,但是我需要自动布局...

Disabling Autolayout, the error disappears, but i need Autolayout...

当我使用自定义单元格"或标准单元格"时出现错误...

The error appears, when I use Custom Cells or StandardCells...

当TableView没有行时出现错误...

The error appears, when the TableView has no rows...

推荐答案

作为此问题的一般解决方案,或者至少是一种找到其原因的方法:

As a general solution to this problem, or at least a way of finding the cause of it:

  • 打开异常断点
  • 子类UITableView并覆盖layoutSublayersOfLayer:,仅调用super
  • 运行您的应用-您将停止使用新方法
  • 在调试器中,键入po [self _autolayoutTrace]
  • Turn on exception breakpoints
  • Subclass UITableView and override layoutSublayersOfLayer:, just calling super
  • Run your app - you will stop in your new method
  • In the debugger, type po [self _autolayoutTrace]

这将向您显示窗口中每个视图的打印输出,其中自动布局无法通过星号或AMBIGUOUS LAYOUT突出显示的解决方案的视图.这些是您需要研究约束的视图.

This will show you a printout of every view in the window, with the views where auto layout has not been able to come up with a solution highlighted by asterisks or AMBIGUOUS LAYOUT. These are the views you need to investigate the constraints for.

这篇关于-[UITableView layoutSublayersOfLayer:]中的断言失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆