iOS如何实现UIAlertView自动关闭功能

这篇文章将为大家详细讲解有关iOS如何实现UIAlertView自动关闭功能,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

为香河等地区用户提供了全套网页设计制作服务,及香河网站建设行业解决方案。主营业务为成都网站设计、网站制作、香河网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

一,效果图。

iOS如何实现UIAlertView自动关闭功能

二,代码。

RootViewController.h
#import 
@interface RootViewController : UIViewController

@end
RootViewController.m
- (void)viewDidLoad
{
 [super viewDidLoad];
 // Do any additional setup after loading the view.
 //alert
 UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"一个可以自动关闭的Alert窗口" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
 [alert show];
 //显示框
 UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
 indicator.backgroundColor=[UIColor redColor];
 indicator.center = CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height-40.0);
 [indicator startAnimating];
 [alert insertSubview:indicator atIndex:0];
 //定时器
 [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(dismissAlert:) userInfo:[NSDictionary dictionaryWithObjectsAndKeys:alert, @"alert", @"testing ", @"key" ,nil] repeats:NO];
}
//alert 自动消失
-(void) dismissAlert:(NSTimer *)timer{
 UIAlertView *alert = [[timer userInfo] objectForKey:@"alert"];
 [alert dismissWithClickedButtonIndex:0 animated:YES];
}

关于“iOS如何实现UIAlertView自动关闭功能”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


网站标题:iOS如何实现UIAlertView自动关闭功能
转载来于:http://bzwzjz.com/article/pccggd.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 教育网站设计方案 定制网站制作 成都网站建设公司 重庆网站建设 成都网站设计 成都网站建设 成都品牌网站设计 成都网站设计 重庆企业网站建设 四川成都网站设计 专业网站设计 网站建设费用 定制级高端网站建设 成都定制网站建设 高端定制网站设计 定制网站设计 泸州网站建设 高端网站建设 H5网站制作 成都网站建设 营销型网站建设 成都网站建设公司