IOS消息框,定时关闭

来源:互联网 发布:js检验只能输入数字 编辑:程序博客网 时间:2024/05/22 23:59

IOS消息框,定时关闭

+(void)SHowMsg

{

NSString *strMsg = [NSString stringWithFormat:@"消息"];

lertView alloc] initWithTitle:@"提示" message:strMsg delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];

//设置时间间隔

float time = 2.0f;

        [NSTimer scheduledTimerWithTimeInterval:time
                                         target:self
                                       selector:@selector(timerFireMethod:)
                                       userInfo:alert
                                        repeats:YES];

        [alert show];

}

+(void)timerFireMethod:(NSTimer*)theTimer//弹出框
{
    UIAlertView *alert= (UIAlertView*)[theTimer userInfo];
    [alertdismissWithClickedButtonIndex:0 animated:NO];
    alert= NULL;
}


0 0
原创粉丝点击