lixiang1994 / LEEAlert

优雅的可自定义 Alert ActionSheet
MIT License
1.3k stars 203 forks source link

window 管理有问题 #115

Closed hw20101101 closed 4 years ago

hw20101101 commented 4 years ago

这是我从 Bugly 上面得到的崩溃信息:

#0 Thread

NSInvalidArgumentException

-[LEEAlertViewController pushViewController:animated:]: unrecognized selector sent to instance 0x157f10540
lixiang1994 commented 4 years ago

可以发一下复现的详细场景吗?

hw20101101 commented 4 years ago

App 线上的崩溃信息,我也不知道用户是怎样操作的

lixiang1994 commented 4 years ago

你是否在其他地方获取了最顶层Controller? 然后调用了push操作

hw20101101 commented 4 years ago
UINavigationController *nav = (UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *vc = [[UIViewController alloc] init];
[nav pushViewController:vc animated:YES];

获取 nav 时出了问题

lixiang1994 commented 4 years ago

太粗暴了..

lixiang1994 commented 4 years ago

直接获取的情况太复杂了, 建议做全判断. 给你一个参考 https://github.com/devxoul/URLNavigator/blob/master/Sources/URLNavigator/UIViewController%2BTopMostViewController.swift 你可以照着写个OC的.

lixiang1994 commented 4 years ago

而且建议直接从你的主window上查找, 不要使用keywindow, keywindow不太可控.

hw20101101 commented 4 years ago

好的,多谢! 😸