资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

iOS如何实现UIAlertView自动关闭功能-创新互联

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

创新互联是少有的成都网站建设、成都网站制作、营销型企业网站、小程序开发、手机APP,开发、制作、设计、友情链接、推广优化一站式服务网络公司,成立于2013年,坚持透明化,价格低,无套路经营理念。让网页惊喜每一位访客多年来深受用户好评

一,效果图。

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自动关闭功能”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页标题:iOS如何实现UIAlertView自动关闭功能-创新互联
网站路径:http://cdkjz.cn/article/djdjes.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220