diff --git a/LMAlertView/CALayer+ModalAlert.m b/LMAlertView/CALayer+ModalAlert.m index 085311c..cc98842 100644 --- a/LMAlertView/CALayer+ModalAlert.m +++ b/LMAlertView/CALayer+ModalAlert.m @@ -25,9 +25,18 @@ + (void)load - (UIWindow *)windowForView:(UIView *)view { + if (![view respondsToSelector:@selector(superview)]) { + return nil; + } + UIView *tempView = view; while (tempView.superview != nil) { + + if (![tempView respondsToSelector:@selector(superview)]) { + break; + } + tempView = tempView.superview; if ([tempView isKindOfClass:[UIWindow class]]) {