HomeiOS Developmentios - Ought to I take advantage of viewDidLayoutSubviews() or traitCollectionDidChange() to...

ios – Ought to I take advantage of viewDidLayoutSubviews() or traitCollectionDidChange() to answer modifications in interface orientation


From what I perceive, each viewDidLayoutSubviews() and traitCollectionDidChange() are ready to answer modifications within the interface orientation (e.g. when the gadget is rotated).

In accordance with Apple’s documentation, for viewDidLayoutSubviews(),

When the bounds change for a view controller’s view, the view adjusts the positions of its subviews after which the system calls this methodology.

Right here I am assuming that when the gadget is rotated, the view’s body will get up to date and the bounds will get up to date similtaneously properly.

As for traitCollectionDidChange(), I perceive that the traitCollection property of UIViewController comprises data of all of the traits belonging to the present iOS atmosphere, which incorporates not solely traits just like the horizontal and vertical measurement lessons, but in addition traits like consumer interface fashion, which is in command of setting darkish and lightweight mode.

Therefore my query is, which methodology ought to I be utilizing to answer modifications within the interface orientation? Is there any computational benefit of utilizing one methodology over the opposite/which one is extra architecturally sound?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments