Created
June 14, 2014 03:53
-
-
Save annidy/c3ae041bc0312ef62245 to your computer and use it in GitHub Desktop.
获取能用于显示的baseview,排除警告框
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)baseView | |
{ | |
BOOL hasAlertView = FALSE; | |
UIView* baseView = [UIApplication sharedApplication].keyWindow; | |
for (UIWindow* w in [UIApplication sharedApplication].windows) { | |
for (UIView *o in w.subviews) | |
{ | |
[self dismissAlertView:o didDismiss:&hasAlertView]; | |
} | |
} | |
if (hasAlertView) { | |
baseView = [[UIApplication sharedApplication].windows objectAtIndex:0]; | |
} | |
return baseView; | |
} | |
- (void)dismissAlertView:(UIView *)w didDismiss:(BOOL*)hasAlertView | |
{ | |
if ([w respondsToSelector:@selector(dismissWithClickedButtonIndex:animated:)] && [w respondsToSelector:@selector(cancelButtonIndex)]) | |
{ | |
[(UIAlertView *)w dismissWithClickedButtonIndex:[(UIAlertView *)w cancelButtonIndex] animated:NO]; | |
*hasAlertView = YES; | |
return; | |
} | |
for (UIView *o in w.subviews) { | |
[self dismissAlertView:o didDismiss:hasAlertView]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment