ios - UIView 标题导致约束问题 XIB Xcode
问题描述
我有一个具有 5 个子 UIViewController 的 UITabBarController,每个子 UIViewController 都是一个 UINavigationViewController。
对于任何 UINavigationControllers 中的 UIView,如果我通过在 viewDidLoad 中设置标题
self.title=@"TITLE";
然后我得到以下不满足的约束错误
2020-05-28 14:21:23.055778+0100 Datum Connect[6515:10336196] [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.
("= UILayoutGuide:0x600001968540'TitleView(0x7fa0a710a390)'.top (active)>", "")
我的 XIB 中没有设置任何约束。这是相当旧的(~2013)代码,所以自动生成的布局可能存在弃用问题......?
但是如果我使用
self.tabBarController.navigationItem.title = @"TITLE";
or
self.navigationController.navigationItem.title=@"TITLE";
or
self.navigationController.title=@"TITLE";
没有约束问题,但 TITLE 文本也没有出现,只是空的导航栏。
解决方案
我不确定您的问题,但如果视图没有限制,则不会有警告。
尝试添加这个
translatesAutoresizingMaskIntoConstraints = NO;
在你看来。
推荐阅读
- android - 当我按下按钮连接到树莓派时应用程序崩溃
- swing - 如何创建具有零宽度边框的 JComboBox?
- android - Android:使用 FirebaseUI 从孩子那里读取值
- java - 共享 char 数组上的 Java 多线程竞争条件
- angular - 通过 Syncfusion Essential JS 2 Grid for Angular 5 导出为 word
- vb.net - 如何保存动态添加的按钮以供下次在 vb.net 中运行
- c# - C# HttpWebRequest.BeginGetResponse 块在一个类中,但不在另一个类中
- javascript - 如何将包含 id 和子引用的对象数组更改为嵌套树结构对象?
- php - codeigniter 中的会话不起作用
- netty - 从管道中删除 HttpObjectAggregator 时,Netty 服务器没有返回响应