iosobjective-cscreen-rotationportraitios16

IOS16 portrait rotate issue


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);
    }];

Solution

  • Calling

     self.setNeedsUpdateOfSupportedInterfaceOrientations()
    

    before requesting the geometry update fixes it for me.