A UIImageView and UIStackView walk into a bar and sit next to each other

Setup

  • I have a UIView with two top level elements:
    • A UIImageView bounded to the top, left and right of it's supverview.
    • A UIStackView bounded to the bottom, left and right of the superview. The stack view has many other nested stack views with labels and, images.
  • In between the two views is a vertical constraint.
  • The stack view and all of it's descendants have the default
    • Vertical Content Hugging Priority of 250.
    • Vertical Content Compression Resistance Priority of 750.
  • The image view has
    • Vertical Content Hugging Priority of 240.
    • Vertical Content Compression Resistance Priority of 740.


Desired Outcome

  • The stack view takes up its intrinisic size as defined by all of its subviews.
  • The image view expands to fill the remaining top of the view.


Success with just a UIView

I first set this up using a UIView instead of a UIImageView and it worked beautifully.

Failure with a UIImageView

When I later removed the UIView and replaced it with a UIImageView containing an image with a height less than the imageview height, the imageview shrinks and the stack view expands. I think the imagview shrinks according to the image it contains, and the stack view expands to fill in the remaining content.

Debugging

I've listed below the the output of _autolayoutTrace and constraintsAffectingLayoutForAxis for both setups.

With a UIView, there's no ambiguity in the layout.

With a UIImageView it shows ambigious layout for the stack view. But I think this is only because the stack view is forced to expand greater than its intrinsic size and there aren't enough rules to dictate what should occur.

Question

Am I correct in that the the intrinsic size of the image view is causing the stack view to expand?

And if so, how can I indicate to the auto layout engine that the intrinsic size of the stack view is more important than the intrinsic size of the image view?

Everything works with a UIView:

(lldb) po self.view.window?.performSelector("_autolayoutTrace")
•UIWindow:0x7f8139f29770
|   •UIView:0x7f8139f1f330
|   |   *UIStackView:0x7f8139f2cd50
|   |   |   *UIStackView:0x7f8139f2e420
|   |   |   |   *UILabel:0x7f8139f2e600'The case for doing someth...'
|   |   |   |   *UILabel:0x7f8139f30f20'Just when it's needed mos...'
|   |   |   *UIStackView:0x7f8139f33510
|   |   |   |   *UILabel:0x7f8139f336a0'By ANEED SHANKER'
|   |   |   |   *UIStackView:0x7f8139f33eb0
|   |   |   |   |   *UIStackView:0x7f8139f34040
|   |   |   |   |   |   *UIImageView:0x7f8139f34240
|   |   |   |   |   |   *UILabel:0x7f8139d23ef0'ANEEDSHARKER'
|   |   |   |   |   *UIStackView:0x7f8139d25330
|   |   |   |   |   |   *UIImageView:0x7f8139d255d0
|   |   |   |   |   |   *UILabel:0x7f8139f396a0'ANEEDSHARKER'
|   |   |   *UIStackView:0x7f8139f3b690
|   |   |   |   *UILabel:0x7f8139f3b840'ab.com'
|   |   |   |   *UIStackView:0x7f8139f3bc60
|   |   |   |   |   *UIStackView:0x7f8139f3bdf0
|   |   |   |   |   |   *UIImageView:0x7f8139f3bfa0
|   |   |   |   |   |   *UILabel:0x7f8139f3c220'AB'
|   |   |   |   |   *UIStackView:0x7f8139f3cff0
|   |   |   |   |   |   *UIImageView:0x7f8139f3d180
|   |   |   |   |   |   *UILabel:0x7f8139f3d3d0'ABCDEFNEWS'
|   |   |   *UILabel:0x7f8139f3f900'Lorem ipsum dolor sit ame...'
|   |   *UIView:0x7f8139f41850
|   |   *_UILayoutGuide:0x7f8139f41bd0
|   |   *_UILayoutGuide:0x7f8139f42940

Legend:
  * - is laid out with auto layout
  + - is laid out manually, but is represented in the layout engine because translatesAutoresizingMaskIntoConstraints = YES
  • - layout engine host))

(lldb) e let $view = unsafeBitCast(0x7f8139f41850, UIView.self)
(lldb) po $view.constraintsAffectingLayoutForAxis(UILayoutConstraintAxis(rawValue:1)!)
▿ 40 elements
  - [0] : <NSContentSizeLayoutConstraint:0x7f8139f4ba70 V:[UILabel:0x7f8139f2e600'The case for doing someth...'(57.5)] Hug:250 CompressionResistance:750>
  - [1] : <NSContentSizeLayoutConstraint:0x7f8139f4c150 V:[UILabel:0x7f8139f30f20'Just when it's needed mos...'(26.5)] Hug:250 CompressionResistance:750>
  - [2] : <NSContentSizeLayoutConstraint:0x7f8139f43ff0 V:[UILabel:0x7f8139f336a0'By ANEED SHANKER'(17)] Hug:250 CompressionResistance:750>
  - [3] : <NSContentSizeLayoutConstraint:0x7f8139f52810 V:[UILabel:0x7f8139f396a0'ANEEDSHARKER'(13.5)] Hug:250 CompressionResistance:750>
  - [4] : <NSContentSizeLayoutConstraint:0x7f8139f55d20 V:[UILabel:0x7f8139f3b840'ab.com'(17)] Hug:250 CompressionResistance:750>
  - [5] : <NSContentSizeLayoutConstraint:0x7f8139f5ab00 V:[UILabel:0x7f8139f3c220'AB'(13.5)] Hug:250 CompressionResistance:750>
  - [6] : <NSContentSizeLayoutConstraint:0x7f8139f3f6d0 V:[UILabel:0x7f8139f3f900'Lorem ipsum dolor sit ame...'(11)] Hug:250 CompressionResistance:750>
  - [7] : <NSLayoutConstraint:0x7f8139f43540 V:|-(0)-[UIView:0x7f8139f41850]   (Names: '|':UIView:0x7f8139f1f330 )>
  - [8] : <NSLayoutConstraint:0x7f8139f435e0 V:[UIStackView:0x7f8139f2cd50]-(8)-|   (Names: '|':UIView:0x7f8139f1f330 )>
  - [9] : <NSLayoutConstraint:0x7f8139f43630 V:[UIView:0x7f8139f41850]-(8)-[UIStackView:0x7f8139f2cd50]>
  - [10] : <NSLayoutConstraint:0x7f8139f54820 'UISV-alignment' UIImageView:0x7f8139d255d0.centerY == UILabel:0x7f8139f396a0'ANEEDSHARKER'.centerY>
  - [11] : <NSLayoutConstraint:0x7f8139f55a70 'UISV-alignment' UIStackView:0x7f8139f34040.bottom == UIStackView:0x7f8139d25330.bottom>
  - [12] : <NSLayoutConstraint:0x7f8139f53ff0 'UISV-alignment' UIStackView:0x7f8139f34040.top == UIStackView:0x7f8139d25330.top>
  - [13] : <NSLayoutConstraint:0x7f8139f5cda0 'UISV-alignment' UIImageView:0x7f8139f3bfa0.centerY == UILabel:0x7f8139f3c220'AB'.centerY>
  - [14] : <NSLayoutConstraint:0x7f8139f37750 'UISV-canvas-connection' UIStackView:0x7f8139f2e420.top == UILabel:0x7f8139f2e600'The case for doing someth...'.top>
  - [15] : <NSLayoutConstraint:0x7f8139f4c580 'UISV-canvas-connection' V:[UILabel:0x7f8139f30f20'Just when it's needed mos...']-(0)-|   (Names: '|':UIStackView:0x7f8139f2e420 )>
  - [16] : <NSLayoutConstraint:0x7f8139f53b80 'UISV-canvas-connection' UIStackView:0x7f8139d25330.top == _UILayoutSpacer:0x7f8139f53320'UISV-alignment-spanner'.top>
  - [17] : <NSLayoutConstraint:0x7f8139f53d60 'UISV-canvas-connection' UIStackView:0x7f8139d25330.centerY == UIImageView:0x7f8139d255d0.centerY>
  - [18] : <NSLayoutConstraint:0x7f8139f3ac40 'UISV-canvas-connection' UIStackView:0x7f8139f33eb0.top == UIStackView:0x7f8139f34040.top>
  - [19] : <NSLayoutConstraint:0x7f8139f4fd30 'UISV-canvas-connection' V:[UIStackView:0x7f8139f34040]-(0)-|   (Names: '|':UIStackView:0x7f8139f33eb0 )>
  - [20] : <NSLayoutConstraint:0x7f8139f55780 'UISV-canvas-connection' UIStackView:0x7f8139f33510.top == UILabel:0x7f8139f336a0'By ANEED SHANKER'.top>
  - [21] : <NSLayoutConstraint:0x7f8139f52240 'UISV-canvas-connection' V:[UIStackView:0x7f8139f33eb0]-(0)-|   (Names: '|':UIStackView:0x7f8139f33510 )>
  - [22] : <NSLayoutConstraint:0x7f8139f5c120 'UISV-canvas-connection' UIStackView:0x7f8139f3bdf0.top == _UILayoutSpacer:0x7f8139f5b6c0'UISV-alignment-spanner'.top>
  - [23] : <NSLayoutConstraint:0x7f8139f5c2f0 'UISV-canvas-connection' UIStackView:0x7f8139f3bdf0.centerY == UIImageView:0x7f8139f3bfa0.centerY>
  - [24] : <NSLayoutConstraint:0x7f8139f3ecb0 'UISV-canvas-connection' UIStackView:0x7f8139f3bc60.top == UIStackView:0x7f8139f3bdf0.top>
  - [25] : <NSLayoutConstraint:0x7f8139f5e300 'UISV-canvas-connection' V:[UIStackView:0x7f8139f3bdf0]-(0)-|   (Names: '|':UIStackView:0x7f8139f3bc60 )>
  - [26] : <NSLayoutConstraint:0x7f8139f5bc90 'UISV-canvas-connection' UIStackView:0x7f8139f3b690.top == UILabel:0x7f8139f3b840'ab.com'.top>
  - [27] : <NSLayoutConstraint:0x7f8139f5d040 'UISV-canvas-connection' V:[UIStackView:0x7f8139f3bc60]-(0)-|   (Names: '|':UIStackView:0x7f8139f3b690 )>
  - [28] : <NSLayoutConstraint:0x7f8139f64e20 'UISV-canvas-connection' UIStackView:0x7f8139f2cd50.top == UIStackView:0x7f8139f2e420.top>
  - [29] : <NSLayoutConstraint:0x7f8139f65b20 'UISV-canvas-connection' V:[UILabel:0x7f8139f3f900'Lorem ipsum dolor sit ame...']-(0)-|   (Names: '|':UIStackView:0x7f8139f2cd50 )>
  - [30] : <NSLayoutConstraint:0x7f8139f4c950 'UISV-spacing' V:[UILabel:0x7f8139f2e600'The case for doing someth...']-(0)-[UILabel:0x7f8139f30f20'Just when it's needed mos...']>
  - [31] : <NSLayoutConstraint:0x7f8139f560a0 'UISV-spacing' V:[UILabel:0x7f8139f336a0'By ANEED SHANKER']-(2)-[UIStackView:0x7f8139f33eb0]>
  - [32] : <NSLayoutConstraint:0x7f8139f61260 'UISV-spacing' V:[UILabel:0x7f8139f3b840'ab.com']-(2)-[UIStackView:0x7f8139f3bc60]>
  - [33] : <NSLayoutConstraint:0x7f8139f66000 'UISV-spacing' V:[UIStackView:0x7f8139f2e420]-(5)-[UIStackView:0x7f8139f33510]>
  - [34] : <NSLayoutConstraint:0x7f8139f4ca40 'UISV-spacing' V:[UIStackView:0x7f8139f33510]-(5)-[UIStackView:0x7f8139f3b690]>
  - [35] : <NSLayoutConstraint:0x7f8139f54950 'UISV-spacing' V:[UIStackView:0x7f8139f3b690]-(5)-[UILabel:0x7f8139f3f900'Lorem ipsum dolor sit ame...']>
  - [36] : <NSLayoutConstraint:0x7f8139f507a0 'UISV-spanning-boundary' _UILayoutSpacer:0x7f8139f53320'UISV-alignment-spanner'.top <= UILabel:0x7f8139f396a0'ANEEDSHARKER'.top>
  - [37] : <NSLayoutConstraint:0x7f8139f5ba50 'UISV-spanning-boundary' _UILayoutSpacer:0x7f8139f5b6c0'UISV-alignment-spanner'.top <= UILabel:0x7f8139f3c220'AB'.top>
  - [38] : <NSLayoutConstraint:0x7f8139f65270 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7f8139f1f330(667)]>
  - [39] : <NSAutoresizingMaskLayoutConstraint:0x7f8139f26070 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' V:|-(0)-[UIView:0x7f8139f1f330]   (Names: '|':UIWindow:0x7f8139f29770 )>

(lldb) e let $stackview = unsafeBitCast(0x7f8139f2cd50, UIStackView.self)
(lldb) po $stackview.constraintsAffectingLayoutForAxis(UILayoutConstraintAxis(rawValue:1)!)
▿ 38 elements
  - [0] : <NSContentSizeLayoutConstraint:0x7f8139f4ba70 V:[UILabel:0x7f8139f2e600'The case for doing someth...'(57.5)] Hug:250 CompressionResistance:750>
  - [1] : <NSContentSizeLayoutConstraint:0x7f8139f4c150 V:[UILabel:0x7f8139f30f20'Just when it's needed mos...'(26.5)] Hug:250 CompressionResistance:750>
  - [2] : <NSContentSizeLayoutConstraint:0x7f8139f43ff0 V:[UILabel:0x7f8139f336a0'By ANEED SHANKER'(17)] Hug:250 CompressionResistance:750>
  - [3] : <NSContentSizeLayoutConstraint:0x7f8139f52810 V:[UILabel:0x7f8139f396a0'ANEEDSHARKER'(13.5)] Hug:250 CompressionResistance:750>
  - [4] : <NSContentSizeLayoutConstraint:0x7f8139f55d20 V:[UILabel:0x7f8139f3b840'ab.com'(17)] Hug:250 CompressionResistance:750>
  - [5] : <NSContentSizeLayoutConstraint:0x7f8139f5ab00 V:[UILabel:0x7f8139f3c220'AB'(13.5)] Hug:250 CompressionResistance:750>
  - [6] : <NSContentSizeLayoutConstraint:0x7f8139f3f6d0 V:[UILabel:0x7f8139f3f900'Lorem ipsum dolor sit ame...'(11)] Hug:250 CompressionResistance:750>
  - [7] : <NSLayoutConstraint:0x7f8139f435e0 V:[UIStackView:0x7f8139f2cd50]-(8)-|   (Names: '|':UIView:0x7f8139f1f330 )>
  - [8] : <NSLayoutConstraint:0x7f8139f54820 'UISV-alignment' UIImageView:0x7f8139d255d0.centerY == UILabel:0x7f8139f396a0'ANEEDSHARKER'.centerY>
  - [9] : <NSLayoutConstraint:0x7f8139f55a70 'UISV-alignment' UIStackView:0x7f8139f34040.bottom == UIStackView:0x7f8139d25330.bottom>
  - [10] : <NSLayoutConstraint:0x7f8139f53ff0 'UISV-alignment' UIStackView:0x7f8139f34040.top == UIStackView:0x7f8139d25330.top>
  - [11] : <NSLayoutConstraint:0x7f8139f5cda0 'UISV-alignment' UIImageView:0x7f8139f3bfa0.centerY == UILabel:0x7f8139f3c220'AB'.centerY>
  - [12] : <NSLayoutConstraint:0x7f8139f37750 'UISV-canvas-connection' UIStackView:0x7f8139f2e420.top == UILabel:0x7f8139f2e600'The case for doing someth...'.top>
  - [13] : <NSLayoutConstraint:0x7f8139f4c580 'UISV-canvas-connection' V:[UILabel:0x7f8139f30f20'Just when it's needed mos...']-(0)-|   (Names: '|':UIStackView:0x7f8139f2e420 )>
  - [14] : <NSLayoutConstraint:0x7f8139f53b80 'UISV-canvas-connection' UIStackView:0x7f8139d25330.top == _UILayoutSpacer:0x7f8139f53320'UISV-alignment-spanner'.top>
  - [15] : <NSLayoutConstraint:0x7f8139f53d60 'UISV-canvas-connection' UIStackView:0x7f8139d25330.centerY == UIImageView:0x7f8139d255d0.centerY>
  - [16] : <NSLayoutConstraint:0x7f8139f3ac40 'UISV-canvas-connection' UIStackView:0x7f8139f33eb0.top == UIStackView:0x7f8139f34040.top>
  - [17] : <NSLayoutConstraint:0x7f8139f4fd30 'UISV-canvas-connection' V:[UIStackView:0x7f8139f34040]-(0)-|   (Names: '|':UIStackView:0x7f8139f33eb0 )>
  - [18] : <NSLayoutConstraint:0x7f8139f55780 'UISV-canvas-connection' UIStackView:0x7f8139f33510.top == UILabel:0x7f8139f336a0'By ANEED SHANKER'.top>
  - [19] : <NSLayoutConstraint:0x7f8139f52240 'UISV-canvas-connection' V:[UIStackView:0x7f8139f33eb0]-(0)-|   (Names: '|':UIStackView:0x7f8139f33510 )>
  - [20] : <NSLayoutConstraint:0x7f8139f5c120 'UISV-canvas-connection' UIStackView:0x7f8139f3bdf0.top == _UILayoutSpacer:0x7f8139f5b6c0'UISV-alignment-spanner'.top>
  - [21] : <NSLayoutConstraint:0x7f8139f5c2f0 'UISV-canvas-connection' UIStackView:0x7f8139f3bdf0.centerY == UIImageView:0x7f8139f3bfa0.centerY>
  - [22] : <NSLayoutConstraint:0x7f8139f3ecb0 'UISV-canvas-connection' UIStackView:0x7f8139f3bc60.top == UIStackView:0x7f8139f3bdf0.top>
  - [23] : <NSLayoutConstraint:0x7f8139f5e300 'UISV-canvas-connection' V:[UIStackView:0x7f8139f3bdf0]-(0)-|   (Names: '|':UIStackView:0x7f8139f3bc60 )>
  - [24] : <NSLayoutConstraint:0x7f8139f5bc90 'UISV-canvas-connection' UIStackView:0x7f8139f3b690.top == UILabel:0x7f8139f3b840'ab.com'.top>
  - [25] : <NSLayoutConstraint:0x7f8139f5d040 'UISV-canvas-connection' V:[UIStackView:0x7f8139f3bc60]-(0)-|   (Names: '|':UIStackView:0x7f8139f3b690 )>
  - [26] : <NSLayoutConstraint:0x7f8139f64e20 'UISV-canvas-connection' UIStackView:0x7f8139f2cd50.top == UIStackView:0x7f8139f2e420.top>
  - [27] : <NSLayoutConstraint:0x7f8139f65b20 'UISV-canvas-connection' V:[UILabel:0x7f8139f3f900'Lorem ipsum dolor sit ame...']-(0)-|   (Names: '|':UIStackView:0x7f8139f2cd50 )>
  - [28] : <NSLayoutConstraint:0x7f8139f4c950 'UISV-spacing' V:[UILabel:0x7f8139f2e600'The case for doing someth...']-(0)-[UILabel:0x7f8139f30f20'Just when it's needed mos...']>
  - [29] : <NSLayoutConstraint:0x7f8139f560a0 'UISV-spacing' V:[UILabel:0x7f8139f336a0'By ANEED SHANKER']-(2)-[UIStackView:0x7f8139f33eb0]>
  - [30] : <NSLayoutConstraint:0x7f8139f61260 'UISV-spacing' V:[UILabel:0x7f8139f3b840'ab.com']-(2)-[UIStackView:0x7f8139f3bc60]>
  - [31] : <NSLayoutConstraint:0x7f8139f66000 'UISV-spacing' V:[UIStackView:0x7f8139f2e420]-(5)-[UIStackView:0x7f8139f33510]>
  - [32] : <NSLayoutConstraint:0x7f8139f4ca40 'UISV-spacing' V:[UIStackView:0x7f8139f33510]-(5)-[UIStackView:0x7f8139f3b690]>
  - [33] : <NSLayoutConstraint:0x7f8139f54950 'UISV-spacing' V:[UIStackView:0x7f8139f3b690]-(5)-[UILabel:0x7f8139f3f900'Lorem ipsum dolor sit ame...']>
  - [34] : <NSLayoutConstraint:0x7f8139f507a0 'UISV-spanning-boundary' _UILayoutSpacer:0x7f8139f53320'UISV-alignment-spanner'.top <= UILabel:0x7f8139f396a0'ANEEDSHARKER'.top>
  - [35] : <NSLayoutConstraint:0x7f8139f5ba50 'UISV-spanning-boundary' _UILayoutSpacer:0x7f8139f5b6c0'UISV-alignment-spanner'.top <= UILabel:0x7f8139f3c220'AB'.top>
  - [36] : <NSLayoutConstraint:0x7f8139f65270 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7f8139f1f330(667)]>
  - [37] : <NSAutoresizingMaskLayoutConstraint:0x7f8139f26070 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' V:|-(0)-[UIView:0x7f8139f1f330]   (Names: '|':UIWindow:0x7f8139f29770 )>


But doesn't work with a UIImageView:

(lldb) po self.view.window?.performSelector("_autolayoutTrace")
•UIWindow:0x7fdb2b690700 - AMBIGUOUS LAYOUT
|   •UIView:0x7fdb2b71afc0
|   |   *UIImageView:0x7fdb2b713e30
|   |   *UIStackView:0x7fdb2b424aa0
|   |   |   *UIStackView:0x7fdb2b425750
|   |   |   |   *UILabel:0x7fdb2b425930'The case for doing someth...'
|   |   |   |   *UILabel:0x7fdb2b4285d0'Just when it's needed mos...'
|   |   |   *UIStackView:0x7fdb2b42ab70- AMBIGUOUS LAYOUT for UIStackView:0x7fdb2b42ab70.Height{id: 200}
|   |   |   |   *UILabel:0x7fdb2b42ad00'By ANEED SHANKER'
|   |   |   |   *UIStackView:0x7fdb2b42b7e0- AMBIGUOUS LAYOUT for UIStackView:0x7fdb2b42b7e0.Height{id: 186}
|   |   |   |   |   *UIStackView:0x7fdb2b42b970- AMBIGUOUS LAYOUT for UIStackView:0x7fdb2b42b970.Height{id: 113}
|   |   |   |   |   |   *UIImageView:0x7fdb2b42bc30- AMBIGUOUS LAYOUT for UIImageView:0x7fdb2b42bc30.minY{id: 116}
|   |   |   |   |   |   *UILabel:0x7fdb2b42f1e0'ANEEDSHARKER'- AMBIGUOUS LAYOUT for UILabel:0x7fdb2b42f1e0'ANEEDSHARKER'.minY{id: 131}
|   |   |   |   |   *UIStackView:0x7fdb2b430710- AMBIGUOUS LAYOUT for UIStackView:0x7fdb2b430710.Height{id: 177}
|   |   |   |   |   |   *UIImageView:0x7fdb2b4308a0- AMBIGUOUS LAYOUT for UIImageView:0x7fdb2b4308a0.minY{id: 156}
|   |   |   |   |   |   *UILabel:0x7fdb2b721290'ANEEDSHARKER'- AMBIGUOUS LAYOUT for UILabel:0x7fdb2b721290'ANEEDSHARKER'.minY{id: 173}
|   |   |   *UIStackView:0x7fdb2b7232a0- AMBIGUOUS LAYOUT for UIStackView:0x7fdb2b7232a0.minY{id: 325}, UIStackView:0x7fdb2b7232a0.Height{id: 337}
|   |   |   |   *UILabel:0x7fdb2b723450'ab.com'- AMBIGUOUS LAYOUT for UILabel:0x7fdb2b723450'ab.com'.minY{id: 335}
|   |   |   |   *UIStackView:0x7fdb2b723870- AMBIGUOUS LAYOUT for UIStackView:0x7fdb2b723870.minY{id: 252}, UIStackView:0x7fdb2b723870.Height{id: 323}
|   |   |   |   |   *UIStackView:0x7fdb2b723a00- AMBIGUOUS LAYOUT for UIStackView:0x7fdb2b723a00.minY{id: 248}, UIStackView:0x7fdb2b723a00.Height{id: 250}
|   |   |   |   |   |   *UIImageView:0x7fdb2b723bb0- AMBIGUOUS LAYOUT for UIImageView:0x7fdb2b723bb0.minY{id: 253}
|   |   |   |   |   |   *UILabel:0x7fdb2b723e30'AB'- AMBIGUOUS LAYOUT for UILabel:0x7fdb2b723e30'AB'.minY{id: 268}
|   |   |   |   |   *UIStackView:0x7fdb2b724c00- AMBIGUOUS LAYOUT for UIStackView:0x7fdb2b724c00.minY{id: 294}, UIStackView:0x7fdb2b724c00.Height{id: 314}
|   |   |   |   |   |   *UIImageView:0x7fdb2b724d90- AMBIGUOUS LAYOUT for UIImageView:0x7fdb2b724d90.minY{id: 293}
|   |   |   |   |   |   *UILabel:0x7fdb2b724fe0'ABCDEFNEWS'- AMBIGUOUS LAYOUT for UILabel:0x7fdb2b724fe0'ABCDEFNEWS'.minY{id: 310}
|   |   |   *UILabel:0x7fdb2b727610'Lorem ipsum dolor sit ame...'
|   |   *_UILayoutGuide:0x7fdb2b7293b0
|   |   *_UILayoutGuide:0x7fdb2b72a0f0

Legend:
  * - is laid out with auto layout
  + - is laid out manually, but is represented in the layout engine because translatesAutoresizingMaskIntoConstraints = YES
  • - layout engine host

(lldb) e let $imageview = unsafeBitCast(0x7fdb2b713e30, UIImageView.self)
(lldb) po $imageview.constraintsAffectingLayoutForAxis(UILayoutConstraintAxis(rawValue:1)!)
▿ 5 elements
  - [0] : <_UILayoutSupportConstraint:0x7fdb2b723820 V:[_UILayoutGuide:0x7fdb2b7293b0(0)]>
  - [1] : <_UILayoutSupportConstraint:0x7fdb2b70f0d0 V:|-(0)-[_UILayoutGuide:0x7fdb2b7293b0]   (Names: '|':UIView:0x7fdb2b71afc0 )>
  - [2] : <NSContentSizeLayoutConstraint:0x7fdb2b68cbb0 V:[UIImageView:0x7fdb2b713e30(360)] Hug:240 CompressionResistance:740>
  - [3] : <NSLayoutConstraint:0x7fdb2b72ab20 V:[_UILayoutGuide:0x7fdb2b7293b0]-(0)-[UIImageView:0x7fdb2b713e30]>
  - [4] : <NSAutoresizingMaskLayoutConstraint:0x7fdb2b515900 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' V:|-(0)-[UIView:0x7fdb2b71afc0]   (Names: '|':UIWindow:0x7fdb2b690700 )>


(lldb) e let $stackview = unsafeBitCast(0x7fdb2b424aa0, UIStackView.self)
(lldb) po $stackview.constraintsAffectingLayoutForAxis(UILayoutConstraintAxis(rawValue:1)!)
▿ 8 elements
  - [0] : <_UILayoutSupportConstraint:0x7fdb2b723820 V:[_UILayoutGuide:0x7fdb2b7293b0(0)]>
  - [1] : <_UILayoutSupportConstraint:0x7fdb2b70f0d0 V:|-(0)-[_UILayoutGuide:0x7fdb2b7293b0]   (Names: '|':UIView:0x7fdb2b71afc0 )>
  - [2] : <NSContentSizeLayoutConstraint:0x7fdb2b68cbb0 V:[UIImageView:0x7fdb2b713e30(360)] Hug:240 CompressionResistance:740>
  - [3] : <NSLayoutConstraint:0x7fdb2b72ab20 V:[_UILayoutGuide:0x7fdb2b7293b0]-(0)-[UIImageView:0x7fdb2b713e30]>
  - [4] : <NSLayoutConstraint:0x7fdb2b72abc0 V:[UIImageView:0x7fdb2b713e30]-(8)-[UIStackView:0x7fdb2b424aa0]>
  - [5] : <NSLayoutConstraint:0x7fdb2b72ab70 V:[UIStackView:0x7fdb2b424aa0]-(8)-|   (Names: '|':UIView:0x7fdb2b71afc0 )>
  - [6] : <NSLayoutConstraint:0x7fdb2b533e00 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fdb2b71afc0(667)]>
  - [7] : <NSAutoresizingMaskLayoutConstraint:0x7fdb2b515900 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' V:|-(0)-[UIView:0x7fdb2b71afc0]   (Names: '|':UIWindow:0x7fdb2b690700 )>

Have you tried changing the content mode of your uiimageview

The image view content mode is set to aspect fill because the images are coming from web and are all different sizes and aspect ratios.


I really need the image view to expand and then for the image to fill that space.

Stackview says "Sorry I'm late - what did I miss?"

A UIImageView and UIStackView walk into a bar and sit next to each other
 
 
Q