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

查看:18
本文介绍了-[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天全站免登陆