Search code examples
iosswiftuideviceorientation

Transition not occurring properly in iOS swift?


The function override

func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) { } 

is not triggered when I build and run on iPad devices but it works fine in mobile devices(iphone 5,6,7...). How to solve this??

Thanks in advance!!


Solution

  • This function is not called because iPad has Regular traits for any rotation. Prefer using func viewWillTransition(to: CGSize, with: UIViewControllerTransitionCoordinator) instead.