简体   繁体   中英

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

Calling

 self.setNeedsUpdateOfSupportedInterfaceOrientations()

before requesting the geometry update fixes it for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM