异常情况:
在根视图 tabbarVC 中 present login 失败
代码:
// 代码
if (![[UserService share] isLogin]) {
[self presentViewController:[LoginViewController new] animated:true completion:nil];
}
错误提示:
Warning: Attempt to present on whose view is not in the window hierarchy!
原因:
self可能不是顶层窗口
解决:
if (![[UserService share] isLogin]) {
UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
[rootVC presentViewController:[LoginViewController new] animated:true completion:nil];
}