ios定时自动退出UIAlertView提示框
2011-12-30 22:54
405 查看
今天想在应用里加个自动退出提示框的功能,在网上没找到好的方法,所以自己用定时器做了一个,跟大家分享下,如果有其他更好的方法麻烦提示一下。
//对话框的创建和定时器的初始化
alertView = [[UIAlertView alloc] initWithTitle:@"Result" message:@"Share Success" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
[alertView show];
NSTimer *timer = [[NSTimer timerWithTimeInterval:3 target:self selector:@selector(onTimer) userInfo:nil repeats:NO] retain];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
[timer release];
//timer的执行事件
- (void)onTimer
{
[alertView dismissWithClickedButtonIndex:0 animated:NO]; //退出对话框
}
//对话框的创建和定时器的初始化
alertView = [[UIAlertView alloc] initWithTitle:@"Result" message:@"Share Success" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
[alertView show];
NSTimer *timer = [[NSTimer timerWithTimeInterval:3 target:self selector:@selector(onTimer) userInfo:nil repeats:NO] retain];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
[timer release];
//timer的执行事件
- (void)onTimer
{
[alertView dismissWithClickedButtonIndex:0 animated:NO]; //退出对话框
}
相关文章推荐
- ios:UIAlertView自动消失
- iOS入门编程1--iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- iOS UIScrollView中实现分页滚动--定时自动滚动分页
- iOS系统自带的 **UIAlertView** 以及 屏幕自动旋转的实现
- ios:UIAlertView自动消失
- IOS UIAlertView 提示视图
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- 【代码笔记】iOS-UIAlertView自动关闭
- iOS开发 提示框- UIAlertController(是UIAlertView和UIActionSheet的合二为一)
- ios:UIAlertView自动消失
- ios:UIAlertView自动消失
- 系统提示 点击其他关闭 alert iOS之UIAlertView点击窗口之外区域关闭
- 【代码笔记】iOS-UIAlertView自动关闭
- ios:UIAlertView自动消失
- ios:UIAlertView自动消失
- iOS-UIAlertView弹框2秒后自动消失
- iOS 自带三种提示框使用、UIAlertView以及UIAlertController的使用
- ios中UIAlert 提示框自动消失方法,超简单!
- iOS自定义提示弹出框实现类似UIAlertView的效果
- ios:UIAlertView自动消失