iOS——AlertView利用定時器自動消失

UIAlertView *alert;
- (IBAction)Open:(id)sender {
alert = [[UIAlertView alloc]
initWithTitle:@”msg” message:@”sss” delegate:self cancelButtonTitle:@”取消” otherButtonTitles:@”確定”, nil];
[NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO];
[alert show];

}

-(void)performDismiss:(NSTimer*)timer
{
[alert dismissWithClickedButtonIndex:0 animated:NO];

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章