ios - 动态设置 navigationItem.prompt 时获取 LayoutConstraints 警告
问题描述
从数据任务获得结果后,我试图动态设置 navigationItem.prompt。当 datatask 完成时,datatask 本身的数据会在 tableview 中列出,并且 tableview 中列出的项目数应该显示在 navigationItem.prompt 中。
但是,当尝试将提示从 nil 设置为字符串时,我收到下面的 LayoutConstraint 警告。
经过一番研究,我在本教程中找到了一个类似的示例(请参阅延迟任务执行)。在初始视图显示并等待设置提示后,会显示相同的警告。
2019-07-29 13:48:58.337732+0200 GooglyPuff[34677:3058108] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x600003c852c0 h=--& v=--& _UINavigationBarModernPromptView:0x7ff015c26540.width == 0 (active)>",
"<NSLayoutConstraint:0x600003c84e10 UILabel:0x7ff015e24660'Add photos with faces to ...'.centerX == _UINavigationBarModernPromptView:0x7ff015c26540.centerX (active)>",
"<NSLayoutConstraint:0x600003c850e0 UILabel:0x7ff015e24660'Add photos with faces to ...'.trailing <= UILayoutGuide:0x6000026bc000'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600003c84f50 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x6000026bc000'UIViewLayoutMarginsGuide']-(20)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7ff015c26540 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003c850e0 UILabel:0x7ff015e24660'Add photos with faces to ...'.trailing <= UILayoutGuide:0x6000026bc000'UIViewLayoutMarginsGuide'.trailing (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2019-07-29 13:48:58.339602+0200 GooglyPuff[34677:3058108] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x600003c852c0 h=--& v=--& _UINavigationBarModernPromptView:0x7ff015c26540.width == 0 (active)>",
"<NSLayoutConstraint:0x600003c84e10 UILabel:0x7ff015e24660'Add photos with faces to ...'.centerX == _UINavigationBarModernPromptView:0x7ff015c26540.centerX (active)>",
"<NSLayoutConstraint:0x600003c84fa0 UILabel:0x7ff015e24660'Add photos with faces to ...'.leading >= UILayoutGuide:0x6000026bc000'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x600003c84eb0 'UIView-leftMargin-guide-constraint' H:|-(20)-[UILayoutGuide:0x6000026bc000'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7ff015c26540 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003c84fa0 UILabel:0x7ff015e24660'Add photos with faces to ...'.leading >= UILayoutGuide:0x6000026bc000'UIViewLayoutMarginsGuide'.leading (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
解决方案
推荐阅读
- pycharm - 查看在 PyCharm 中播放的动画 GIF
- reactjs - React-virtualized - 是否可以在窗口调整大小时更新 rowHeights?
- windows - 在 C++ 中截取窗口(句柄)的屏幕截图
- raspberry-pi - Sudo apt update 在 rassbery pi 上返回错误示例:N 中的四个:跳过获取已配置文件“main/binary-amd64/Packages”作为存储库
- ios - 在 iOS 中将缓存文件保存到磁盘
- javascript - 检查移动设备上是否启用了 cookie(iOS 上的 Chrome)
- python - 如何使用 BeautifulSoup 从我的 Selenium 结果中抓取?
- python - 如何使用 Python 以 Windows 定义文件的方式获取文件的“最后访问”时间?
- python - 如何在 Spark 中设置 KCL 的属性?
- google-apps-script - 仅在将新行添加到电子表格时创建触发器以运行脚本