Apple says that traitCollectionDidChange(... called when the iOS interface environment changes and willTransition(to:with:) Notifies the container that its trait collection changed. ok. but is there a code i must call strictly in traitCollectionDidChange and not in willTransition and not in viewWillTransition? Why do we need separate traitCollectionDidChange( function? is there condition where we can not substitute traitCollectionDidChange with willTransition???

class VC : UIViewController {
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
    print("\(type(of:self)) \(#function)")
    super.traitCollectionDidChange(previousTraitCollection)
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    print("\(type(of:self)) \(#function)")
    super.viewWillTransition(to: size, with: coordinator)
}
override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
    print("\(type(of:self)) \(#function)")
    super.willTransition(to: newCollection, with: coordinator)
}
}
0

There are 0 answers