Search code examples
swiftstackview

Hide first subview in stackview and other disappears on iOS 10.2 but not 11


Confused on this one...

I have a stackview in a tableview cell. The stackview (Center, Equal Spacing) has two sub stackviews, Left stackview (Fill, Fill) has a UIButton (infoButton) and UILabel (Description) Right stackview (Fill, Fill) has just UILabel

When I set infoButton.isHidden = true, Description is nowhere to be seen on iOS 10.2. On iOS 11.1 it works as expected.

Thanks for taking a look!

Image: iOS 11.1 on left, iOS 10.2 on right.

Additional Info:

if (input.Help == ""){
    aCell.infoButton.isHidden = true
} else {
    aCell.infoButton.isHidden = false
    aCell.infoButton.tag = i
    aCell.infoButton.isUserInteractionEnabled = true
    aCell.infoButton.addGestureRecognizer(tap)
}

Solved: I changed the Stack View (that contains the button and label together) to Alignment 'Center' instead of 'Fill'. The Stackview height had been changing to 0 as observed in the View Debugger (thank you Matt for pointing me to the debugger!)

iOS 11.1 on left, 10.2 on right


Solution

  • Changed the Stack View (that contains the button and label together) to Alignment 'Center' instead of 'Fill'.

    The Stackview height had been changing to 0 as observed in the View Debugger (thank you Matt for pointing me to the debugger!) when one subview of the stack was set to hidden.