Why am I getting a quot;Auto Layout still required after executing -layoutSubviewsquot; error every time my app launches now?(为什么我得到一个“执行 -layoutSubviews 后仍然需要自动布局?每次我的应用程序现在启动时都会出错?)
问题描述
由于我添加了以下代码,每次我的应用打开此 UITableViewController
时它都会崩溃:
Since I added the following code, every time my app opens this UITableViewController
it crashes:
它给了我这个错误:
* 由于未捕获的异常NSInternalInconsistencyException"而终止应用程序,原因:执行 -layoutSubviews 后仍需要自动布局.UITableView的-layoutSubviews的实现需要调用super.'
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.'
我到底做错了什么?当有 0 行时,我在 tableView:numberOfRowsInSection:
中调用该代码.
What on earth am I doing wrong? I call that code in tableView:numberOfRowsInSection:
when there's 0 rows.
推荐答案
我正在继承 UIScrollView 并在 iOS 7(但不是 8)上收到相同的错误消息.
I was subclassing UIScrollView and received the same error message on iOS 7 (but not 8).
我以类似于以下方式覆盖 layoutSubviews:
I was overriding layoutSubviews in a manner similar to the following:
我解决了这个问题,把对 super 的 layoutSubviews 的调用移到方法中的最后一件事:
I resolved the issue by moving the call to super's layoutSubviews to be the last thing in the method:
这篇关于为什么我得到一个“执行 -layoutSubviews 后仍然需要自动布局"?每次我的应用程序现在启动时都会出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!