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

修复AppDelegate没有window属性崩溃问题 #578

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ixueadev
Copy link

@ixueadev ixueadev commented Dec 1, 2021



My issue:

当使用最新Xcode创建的项目时,AppDelegate里面没有window属性,会导致崩溃。

What I have done:

解决方法是在getMainWindow方法中访问AppDelegate属性时,判断是否有该属性,如果有才访问:

static inline UIWindow *getMainWindow(){
    ...
    if ([UIApplication.sharedApplication.delegate respondsToSelector:@selector(window)]) {
        //兼容新版项目结构,也就是AppDelegate没有window的情况
        window = UIApplication.sharedApplication.delegate.window;
    }
    ...
    return window;
}

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

Successfully merging this pull request may close these issues.

1 participant