Views horizontally and vertically are ambiguous with a complex layout

I have UIViewControlleron my storyboard that has 2 sub-items side by side horizontally. I added constraints to fix the leading and trailing edges to the constant (20 points) and another constraint to keep the width equal. If I assume the following, it should be possible to calculate how wide the width of each peep should be:

  • Mobility does not overlap
  • no other views (horizontal, at least)
  • known screen width (supervisor)

However, Xcode gives me a warning that my views are horizontally ambiguous. I guess this means that Xcode does not make one of these assumptions, but who is it? And is there a way to instruct Xcode to make this assumption?

EDIT: Okay, played a little with him and got a warning to leave, but that doesn't seem to make the first assumption - he just sets the width of each subview to superview.width - 40and happily bury one view under another. So, the question is how to stop them overlap?

EDIT 2: Well, my actual screen is much more complicated than my simple example. Here is what I got:

enter image description here

, 4 , . , , subview.frame.size.width = superview.width - 60. , - , ( ) (20 ). 3 , , . , ( ) 20 , , , ( , >= 20 , , 20 ). , UIScrollView UIView.

, , 4 . , , , . , 20 , , . - ? ? , ( , ):

enter image description here

+4
2

, , . . , > 20 , 1000 . , = 20 , 800.

, ( ), Xcode = 20, , , >= 20. >= , = . , Xcode , = 20, , , 20. , , >= 20 .

, TL; DR, , (x) , >= x 1000 a = x < 1000 - . 4 .

, . , (, , ) , . .

  • UIScrollView
  • a UIView UIScrollView, "contentView" .
  • contentView 4 width height ( 6 contentView - 2 , ). , width height - , , , , .
  • , UIScrollView (UIButtons, UILabels ..). UILabel , , - UIView ) contentView, UIScrollView

UILabel, , contentView, , .

, UILabel ( , ), contentView expand :

  • UIScrollView
  • a UIView UIScrollView, "contentView" .
  • contentView 4 width height
  • width contentView (, contentViewWidthConstraint)
  • UILabel s
  • UILabel s
  • width UILabel s

viewWillLayoutSubviews

  • UILabel ( CGFloat, totalWidth)
  • set contentViewWidthConstraint.constant = totalWidth

! , , , , .

+6

, . ( , , ):

Ambiguity example

0.

Screen shot

+5

All Articles