1. 程式人生 > >可以自動消失的彈出提示框

可以自動消失的彈出提示框

+(void)timerFireMethod:(NSTimer*)theTimer{

//彈出框

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

    [promptAlert dismissWithClickedButtonIndex:0animated:NO];

    promptAlert = NULL;

}

+(void)showAlert:(NSString *) _message{

//時間

UIAlertView *promptAlert = [[UIAlertViewalloc] initWithTitle

:@"提示:"message:_message delegate:nilcancelButtonTitle:nilotherButtonTitles:nil];

    [NSTimerscheduledTimerWithTimeInterval:1.5f

target:self

selector:@selector(timerFireMethod:)

userInfo:promptAlert

repeats:YES];

    [promptAlert show];

}