Question: Swift Auto Layout A project includes a UIStackView with vertically arranged views. The task is to change the orientation of the stack view to horizontal

Swift Auto Layout
A project includes a UIStackView with vertically arranged views. The task is to change the orientation of the stack view to horizontal when the device's
orientation changes, from portrait to landscape and vice versa.
Which of the following implementations of the traitCollectionDidChange(_ method achieves this?
Pick ONE option
override func traitCollectionDidChange (_ previousTraitCollection: UITraitCollection?){
super.traitCollectionDidChange(previousTraitCollection)
if traitCollection.verticalSizeClass != previousTraitCollection?.verticalSizeClass {
stackView.axis = traitCollection.verticalSizeClass ==. compact ?. horizontal : .vertical
}
}
 Swift Auto Layout A project includes a UIStackView with vertically arranged

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!