limiting device orientations in IOS16

I understand that shouldAutorotate has been deprecated in IOS16 and forcing orientations using UIDevice have also gone away. But it's not clear to me how we can prevent orientation changes using the new api.

I have managed to force orientation changes using requestGeometryUpdate but nothing I do seems to stop it from rotating back again after the forced rotation.

I've tried calling setNeedsUpdateOfSupportedInterfaceOrientations on both the current view controller and the navigation controller but supportedInterfaceOrientations never seems to be called.

supportedInterfaceOrientations is called on the first load, but it seems to be ignored as regardless of what I put in there the device will rotate to all the options allowed in the info.plist.

What trick am I missing?

Answered by kallipigous in 719963022

I figured it out by trial and error. My problem was that I had a navigationcontroller that was in the way. I had to make sure that navigationControllerSupportedInterfaceOrientations was updated too.

Accepted Answer

I figured it out by trial and error. My problem was that I had a navigationcontroller that was in the way. I had to make sure that navigationControllerSupportedInterfaceOrientations was updated too.

limiting device orientations in IOS16
 
 
Q