Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

iOS 13 获取window方案调整了希望可以修复一下 #29

Open
chenminjie92 opened this issue Nov 16, 2020 · 1 comment
Open

iOS 13 获取window方案调整了希望可以修复一下 #29

chenminjie92 opened this issue Nov 16, 2020 · 1 comment

Comments

@chenminjie92
Copy link

iOS 13 获取window方案调整了希望可以修复一下zix_isAppRootViewController

@wangjinshan
Copy link

  • (BOOL)zix_isAppRootViewController {
    Class XXApplication = NSClassFromString(@"UIApplication");
    id sharedApplication = [XXApplication performSelector:@selector(sharedApplication)];
    id appDelegate = [sharedApplication performSelector:@selector(delegate)];
    XXWindow *window = nil;
    if ([appDelegate respondsToSelector:@selector(window)]) {
    window = [appDelegate performSelector:@selector(window)];
    } else if ([sharedApplication respondsToSelector:@selector(keyWindow)]) {
    window = [sharedApplication performSelector:@selector(keyWindow)];
    } else {
    window = [UIApplication sharedApplication].windows.firstObject;
    }
    XXViewController *rootViewController = window.rootViewController;
    if (rootViewController) {
    return rootViewController == self;
    }
    //Maybe in app extension
    id nextResponder = [self nextResponder];
    if ([nextResponder isKindOfClass:[XXWindow class]]) {
    if ([[nextResponder nextResponder] isKindOfClass:XXApplication]) {
    return YES;
    }
    }
    return NO;
    }

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

No branches or pull requests

2 participants