如何关闭UIAlertView
2014-12-14 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517181
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
开发秘籍中有一个allSubView(),
取应用程序的windows,
static NSArray * allSubviews(UIView * viewSuper)
{
NSArray * arraySubviews = viewSuper.subviews;
for (UIView * subView in viewSuper.subviews)
{
NSArray * arraySub = allSubviews(subView);
if (arraySub != nil)
{
arraySubviews = [arraySubviews arrayByAddingObjectsFromArray:arraySub];
}
}
return arraySubviews;
}
//========
NSMutableArray * arrayAlertView = [NSMutableArray arrayWithCapacity:0];
for (UIWindow * windowSub in [[UIApplication sharedApplication] windows])
{
for (UIView * viewSub in allSubviews(windowSub))
{
if ([viewSub isKindOfClass:[UIAlertView class]])
{
[arrayAlertView addObject:(UIAlertView *)viewSub];
}
}
}
for (UIAlertView * alertView in arrayAlertView)
{
for (UIView * viewSub in alertView.subviews)
{
if ([viewSub isKindOfClass:[UITextField class]])
{
[(UITextField *)viewSub resignFirstResponder];
}
}
[alertView dismissWithClickedButtonIndex:0 animated:YES];
}
取应用程序的windows,
static NSArray * allSubviews(UIView * viewSuper)
{
NSArray * arraySubviews = viewSuper.subviews;
for (UIView * subView in viewSuper.subviews)
{
NSArray * arraySub = allSubviews(subView);
if (arraySub != nil)
{
arraySubviews = [arraySubviews arrayByAddingObjectsFromArray:arraySub];
}
}
return arraySubviews;
}
//========
NSMutableArray * arrayAlertView = [NSMutableArray arrayWithCapacity:0];
for (UIWindow * windowSub in [[UIApplication sharedApplication] windows])
{
for (UIView * viewSub in allSubviews(windowSub))
{
if ([viewSub isKindOfClass:[UIAlertView class]])
{
[arrayAlertView addObject:(UIAlertView *)viewSub];
}
}
}
for (UIAlertView * alertView in arrayAlertView)
{
for (UIView * viewSub in alertView.subviews)
{
if ([viewSub isKindOfClass:[UITextField class]])
{
[(UITextField *)viewSub resignFirstResponder];
}
}
[alertView dismissWithClickedButtonIndex:0 animated:YES];
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询