簡體   English   中英

UIView 標題導致約束問題 XIB Xcode

[英]UIView title causing constraints problem 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;

在你看來。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM