定時消失的Alert彈窗
阿新 • • 發佈:2017-09-06
elb true nim with forms selector select 類方法 --
在公共類裏面寫如下兩個類方法就可以了,只需要把第一個類方法公布出來:
代碼如下:
#pragma mark --- 定時彈窗 --- + (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message afterDelay:(NSTimeInterval)delay { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]; [alert show]; [self performSelector:@selector(dimissAlert:) withObject:alert afterDelay:delay]; } + (void)dimissAlert:(UIAlertView *)alert { if(alert) { [alert dismissWithClickedButtonIndex:[alert cancelButtonIndex] animated:YES]; } }
定時消失的Alert彈窗