Art*_*rMe 0 timer nstimer uialertview ios
我正试图UIAlertView
用一个timer
.例如:用户设置时间,用户点击按钮,UIAlertView
弹出,在alertView中有一个计时器,显示用户在操作开始前必须等待多长时间.
在搜索网络时,我只找到了如何显示已经过了多少时间.有没有办法每秒更新UIAlertView以显示计时器?时间过后,UIAlertView需要被解雇,并且必须调用空白.
尝试喜欢它.
UIAlertView *autosaveAlert = [[UIAlertView alloc]initWithTitle:@"Close" message:@"Autosave in (%d) seconds" delegate:self cancelButtonTitle:@"Press to cancel" otherButtonTitles:nil];
[autosaveAlert show];
for(int i = 10; i>=0; i--){
NSString *tmp = @"Close in (%d) seconds";
NSString *str = [NSString stringWithFormat:tmp, i];
[autosaveAlert setMessage:str];
CFRunLoopRunInMode(kCFRunLoopDefaultMode,1, false);
}
[autosaveAlert dismissWithClickedButtonIndex:0 animated:TRUE];
Run Code Online (Sandbox Code Playgroud)