簡體   English   中英

如何為我的視圖解決自動布局約束

[英]How to resolve auto layout constraints for my view

自動布局警告 故事板截圖 我需要你的幫助。 如何解決自動布局的警告。

以下是我的組件層次結構:

查看 Controller
看法
- 看法
--表格視圖
---表格單元格
1. 標題 Label
2. 編輯按鈕
3.刪除按鈕

我提供了如下約束:

標題 label:

Leading space to superview
trailing space to Edit button
bottom space to superview
top space to superview  

編輯按鈕

trailing space to remove button
leading space to title label
bottom space to superview
top space to superview

刪除按鈕

Trailing space to superview
width = 40
leading space to edit button
align center Y
height = 40

我收到標題 label、編輯和刪除按鈕的警告“需要 X 和寬度”。

有什么幫助嗎?

Edit button寬度約束設置為 40 與刪除按鈕寬度相同。

編輯按鈕

trailing space to remove button
leading space to title label
width = 40  
bottom space to superview
top space to superview

如果按鈕寬度不固定,那么您需要更新內容擁抱優先Horizontal值。

Select 編輯按鈕並將Content Hugging Priority Horizontal ntal 值從 250 更改為 251

或者

Select Title Label 並將Content Hugging Priority Horizontal ntal 值從 250 更改為 249

在此處輸入圖像描述

希望這會有所幫助。

我建議您為 storyboard 組件使用自動布局固定按鈕,我重新創建了您的視圖,這就是我為組件所做的。

對於標題 Label:

按鈕的約束

對於按鈕:

在此處輸入圖像描述

按鈕對齊

對於刪除按鈕:

在此處輸入圖像描述

最后修復了 label 的尾隨空間問題。

在此處輸入圖像描述

暫無
暫無

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

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