UIStackView Bug

Sometimes you set items in UIStackView and it doesn’t work.
The bug is that hiding and showing views in a stack view is cumulative. Weird Apple bug. If you hide a view in a stack view twice, you need to show it twice to get it back.
http://www.openradar.me/25087688

To fix this issue you can use the following extension:

1
2
3
4
5
6
7
8
9
10
11
12
extension UIView {
var isHiddenInStackView: Bool {
get {
return isHidden
}
set {
if isHidden != newValue {
isHidden = newValue
}
}
}
}

and use:

1
stackView.subviews[someIndex].isHiddenInStackView = false
© 2020 Vien's Blog All Rights Reserved.
Theme by hiero