IOS16 portrait rotate issue

556 Views Asked by At

Hi I wanna fix the bug which occur in IOS16 for rotation screen I refer to this article, but it's still not working....

BTW we used the Object-c instead of Swift

Reference

    UIWindowScene  *windowScene  = ( UIWindowScene  *)[[[ UIApplication sharedApplication] connectedScenes]      allObjects].firstObject;
     UIWindowSceneGeometryPreferencesIOS  *perference  = [[ UIWindowSceneGeometryPreferencesIOS alloc]  init];
    perference.interfaceOrientations  =  1  < deviceOrientation;
    [windowScene requestGeometryUpdateWithPreferences:perference errorHandler: ^( NSError  * _Nonnull error) {
         NSLog(@ "error--%@", error);
    }];
1

There are 1 best solutions below

1
DenseCrab On BEST ANSWER

Calling

 self.setNeedsUpdateOfSupportedInterfaceOrientations()

before requesting the geometry update fixes it for me.