iOS16强制屏幕方向失效问题

1.背景:某一天发现unity开发的游戏在iOS16.2上会偶现出现竖屏的情况(supportedInterfaceOrientationsForWindow里已限制只能左右旋转)以下方法都不管用

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window;
if (@available(iOS 16.0, *)) {
    [vc.navigationController setNeedsUpdateOfSupportedInterfaceOrientations];
  
    NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
    UIWindowScene *ws = (UIWindowScene *)array[0];
    UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init];
    geometryPreferences.interfaceOrientations = UIInterfaceOrientationMaskLandscapeLeft;
    [ws requestGeometryUpdateWithPreferences:geometryPreferences
        errorHandler:^(NSError * _Nonnull error) {
        //业务代码
    }];
}

2.游戏引擎:Unity 2019
最后发现:游戏退出的时候调用UnityCleanup函数,il2cpp会清理一些子线程,由于c#子线程在wait,过5s清理不掉就会导致一个crash

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容