About the "setNeedsUpdateOfSupportedInterfaceOrientations" function

I have a screen rotation problem on iOS16. I found that it can be improved by adding the following processing.

if (@available(iOS 16.0, *)) {
    UIWindowScene *windowScene = (UIWindowScene *)[[[UIApplication sharedApplication] connectedScenes] allObjects].firstObject;
    UIViewController *rootView = [[windowScene keyWindow] rootViewController];
    [rootView setNeedsUpdateOfSupportedInterfaceOrientations];
}

It worked fine when built with XCode14. But it also worked fine when built with XCode13. Why is this? Can "setNeedsUpdateOfSupportedInterfaceOrientations" be used without XCode14?

The code as stated should not be used anywhere. You are just asking for a random scene, which might be a totally different one than the one that's currently on screen. Same goes for the key window.

To answer your question you'd need to explain more of what the actual issue is you are seeing, what you are doing with interface orientations right now and probably also show some code of how you are handling rotations and supported orientations right now.

About the "setNeedsUpdateOfSupportedInterfaceOrientations" function
 
 
Q