簡體   English   中英

如果設置為隱藏,iOS UIStackView無法同時滿足約束

[英]iOS UIStackView unable to simultaneously satisfy constraints if set hidden

我在引用UIStackView問題。 我創建了一個StackView並添加了一些捆綁到另一個StackViews中的項目。 現在,我想使用隱藏屬性為內部StackView設置動畫,以在不同對象之間切換。 為此,我呼吁StackView.hidden在代碼ViewDidLoad隱藏的StackView在它的項目。 代碼似乎在模擬器中工作,但它會拋出一個錯誤:

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. 
(
    "<NSLayoutConstraint:0x7fd29d00b460 'UISV-canvas-connection' UIStackView:0x7fd29acdb3b0.top == UIStackView:0x7fd29acdc120.top>",
    "<NSLayoutConstraint:0x7fd29d00b5a0 'UISV-canvas-connection' V:[UISlider:0x7fd29accb620]-(0)-|   (Names: '|':UIStackView:0x7fd29acdb3b0 )>",
    "<NSLayoutConstraint:0x7fd29d00f8d0 'UISV-hiding' V:[UIStackView:0x7fd29acdb3b0(0)]>",
    "<NSLayoutConstraint:0x7fd29d00b9a0 'UISV-spacing' V:[UIStackView:0x7fd29acdc120]-(10)-[UISlider:0x7fd29accb620]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fd29d00b9a0 'UISV-spacing' V:[UIStackView:0x7fd29acdc120]-(10)-[UISlider:0x7fd29accb620]>

我將內部StackView中的問題確定為Spacing。 如果我將間距切換為0,問題就會消失。 但我不想錯過間距。 我認為另一種選擇是隱藏內部StackView中的每個對象,但這是一項巨大的工作,並且隱藏StackView更加簡單。 有什么想法解決這個問題嗎?

謝謝你的幫助!

僅供將來參考:當我想要隱藏UIStackView時,我已經發生了這種情況。 我建議你把UIStackView隱藏在另一個UIStackView中,其分布設置為填充不按比例填充

暫無
暫無

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

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