Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

iOS16 横屏时候用默认的show会导致后面画面变形,追踪代码是 [leeWindow makeKeyAndVisible]造成的 #173

Open
JasonLxj opened this issue Sep 19, 2022 · 12 comments

Comments

@JasonLxj
Copy link

JasonLxj commented Sep 19, 2022

大概得一个复现代码如下,两个方法,先调用 onHorClick: 然后调用 onLandClick:
调用 onLandClick:的时候效果如下:

// SceneDelegate.m
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    if ([scene isKindOfClass:[UIWindowScene class]]) {
        UIWindowScene *windowScene = (UIWindowScene *)scene;
        [LEEAlert configMainWindow:windowScene.windows.firstObject];
    }
    
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
}

// ViewController.m
- (IBAction)onHorClick:(id)sender {
    NSArray *sceneArray = [[[UIApplication sharedApplication] connectedScenes] allObjects];
    UIWindowScene *scene = sceneArray.firstObject;
    if (scene) {
        UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:UIInterfaceOrientationMaskLandscapeLeft];
        [scene requestGeometryUpdateWithPreferences:geometryPreferences
                                       errorHandler:^(NSError * _Nonnull error) {
            NSLog(@"%@", error.localizedDescription);
        }];
    }
}

- (IBAction)onLandClick:(id)sender {
    LEEAlert.alert.config.LeeAddTitle(^(UILabel * _Nonnull label) {
        label.text = @"测试文字";
    })
    .LeeAddAction(^(LEEAction *action) {
        action.type = LEEActionTypeDefault;
        action.clickBlock = ^{
            NSLog(@"%@", @"点击了");
        };
    })
    .LeeAddAction(^(LEEAction *action) {
        action.type = LEEActionTypeCancel;
        action.clickBlock = ^{
            NSLog(@"%@", @"点击了");
        };
    })
    .LeeShow();
}

1111

112.mp4
@JasonLxj
Copy link
Author

经过测试,将 show 里面的 [[LEEAlert shareManager].leeWindow makeKeyAndVisible]; 注释掉,弹窗可以正常显示,而且后面的页面也显示正常。不知道这样是否有别的隐患。

@lixiang1994
Copy link
Owner

你的项目使用的是SceneDelegate吗?

@lixiang1994
Copy link
Owner

刚刚发布了 1.6.1版本, 你可以更新一下试试, iOS13以上不再调用makeKeyAndVisible

@JasonLxj
Copy link
Author

刚刚发布了 1.6.1版本, 你可以更新一下试试, iOS13以上不再调用makeKeyAndVisible
刚才试了下,貌似还有别的问题。关闭弹窗的时候,会有一个屏幕旋转的过程。这里弄了个demo,如果有时间你可以看下效果。

Simulator.Screen.Recording.-.iPhone.14.-.2022-09-20.at.21.34.58.mp4

@JasonLxj
Copy link
Author

你的项目使用的是SceneDelegate吗?

使用了。

@lixiang1994
Copy link
Owner

视频中关闭的时候 window又变了 我猜测是不是和[[LEEAlert shareManager].leeWindow resignKeyWindow];有关, 你可以尝试注释掉它吗?

@JasonLxj
Copy link
Author

视频中关闭的时候 window又变了 我猜测是不是和[[LEEAlert shareManager].leeWindow resignKeyWindow];有关, 你可以尝试注释掉它吗?

刚试了下,不行,感觉是系统管理多Window的问题。。

@BigPoro
Copy link

BigPoro commented Oct 13, 2022

视频中关闭的时候 window又变了 我猜测是不是和[[LEEAlert shareManager].leeWindow resignKeyWindow];有关, 你可以尝试注释掉它吗?

我没有使用SceneDelegate,注释该行代码后bug解决。

@lixiang1994
Copy link
Owner

@JasonLxj @BigPoro @kaelding 麻烦各位试一下1.6.4版本是否还有该问题, 如果已经解决 我好关闭这个issue

@JacketXia
Copy link

@JasonLxj @BigPoro @kaelding 麻烦各位试一下1.6.4版本是否还有该问题, 如果已经解决 我好关闭这个issue

我项目中使用了1.6.4版本,在iOS16且横屏的情况下,弹出弹窗是没问题的,关闭弹窗时,还是有屏幕旋转的问题。

@lixiang1994
Copy link
Owner

@JasonLxj @BigPoro @kaelding 麻烦各位试一下1.6.4版本是否还有该问题, 如果已经解决 我好关闭这个issue

我项目中使用了1.6.4版本,在iOS16且横屏的情况下,弹出弹窗是没问题的,关闭弹窗时,还是有屏幕旋转的问题。

可以用demo复现一下吗? 我好像没有搞出来

@syp1027825441
Copy link

为什么一定要用一个新的window呢,直接加载keywindow上或者appdelegate中的window上不行吗

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants