点击按钮会将用户带到应用程序的不同部分(不同的VC).用户通过连接到推送segue的按钮返回主菜单.但是,当应用程序再次加载主菜单VC时,它会崩溃并显示以下消息:
2014-08-28 16:11:14.122 * Assertion failure in -[UIView layoutSublayersOfLayer:],/SourceCache/UIKit_Sim/UIKit-2935.137/UIView.m:8803
2014-08-28 16:11:14.257 * Terminating app due to uncaught exception ‘NSInternalInconsistencyException’,reason: ‘Auto Layout still required after sending -viewDidLayoutSubviews to the view controller. LVSMainViewController’s implementation needs to send -layoutSubviews to the view to invoke auto layout.’
SO上的其他帖子在以编程方式设置自动布局约束时报告相同的错误(我没有这样做,虽然我在故事板中使用自动布局)和/或使用UITableView时(我在主菜单中没有使用) VC或它所代表的VC,虽然我在应用程序的其他地方使用它). (见here或here.)
其他拼图:
>我尝试添加[self.view layoutSubviews];在-viewDidLayoutSubviews结束时.当我这样做时它不会崩溃.但自从Apple’s documentation年以来,这似乎是不明智的
You should not call this method directly. If you want to force a
layout update,call the setNeedsLayout method instead to do so prior
to the next drawing update.
>如果我改为添加[self.view setNeedsLayout];在-viewDidLayoutSubviews结束时,应用程序崩溃首先加载主菜单VC,而不是当我离开它并返回时.
可能是什么造成的?
解决方法
您可以通过调用[self.view layoutSubviews]来接近答案.
请尝试调用[self.view layoutIfNeeded].
看这些帖子:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。