My wish is to have a UIStackView added in the Storyboard with 0 height that I reference in the code to add subviews to programatically. However, Storyboard is complaining about that it doesn't have a height (I haven't set it, so it is correct that it warns me). I only want it to act as a dynamic container for other views. The UIStackView I am talking about is added as a subview inside another UIStackView.
It is the stackview below "Name Label" it is all about.
You can hide you inner stack view using the boolean .hidden
property. Create an outlet to the inner stack view, say innerStackView
, and hide it at initialization using innerStackView.hidden = true
, eg:
@IBOutlet weak var innerStackView: UIStackView!
override func viewDidLoad() {
super.viewDidLoad()
// ...
innerStackView.hidden = true
}
This will hide the stack view even if it contains several other views; hence, it can act as your hidden dynamic container, and you needn't fiddle around with height properties. If you want to show the view again, simply bitswap the .hidden
property to innerStackView.hidden = false
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.