首页 > 其他 > 详细

关于UIAlertView弹出警告框自动消失

时间:2016-03-24 16:05:21      阅读:192      评论:0      收藏:0      [点我收藏+]

 

很多事时候弹出框只是为了提示用户,为了避免让用户过多不必要的操作,让弹出框自动消失就可以了

 

+ (void)showDismissedAlertDialog:(NSString*)message {

    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil   //NSLocalizedString(@"错误", nil)

                                                    message:NSLocalizedString(message, nil)

                                                   delegate:self

                                          cancelButtonTitle:nil

                                          otherButtonTitles:nil, nil];

        

    [NSTimer scheduledTimerWithTimeInterval:1.5f

                                     target:self

                                   selector:@selector(timerFireMethod:)

                                   userInfo:alert

                                    repeats:YES];    //弹出框消失倒计时

    

    [alert show];

}

 

 

#pragma mark -- 弹出框自动消失  使用倒计时

+ (void)timerFireMethod:(NSTimer*)theTimer//弹出框

{

    

    UIAlertView *promptAlert = (UIAlertView*)[theTimer userInfo];

    

    [promptAlert dismissWithClickedButtonIndex:0 animated:NO];

    promptAlert = nil;

    

    [theTimer invalidate];//使计时器无效

}

 

关于UIAlertView弹出警告框自动消失

原文:http://www.cnblogs.com/qwer-BHS/p/5315658.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!