UIAlertController
2016-04-26 09:33
387 查看
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@"提示"
message:@"确定要退出吗?"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction
actionWithTitle:@"取消"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *
_Nonnull action) {
}];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:@"确定"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *
_Nonnull action) {
[LCProgressHUD
showLoading:@"正在退出...."];
[NSTimer
scheduledTimerWithTimeInterval:TIME
target:self
selector:@selector(getOutID)
userInfo:nil
repeats:NO];
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[self
presentViewController:alertController animated:YES
completion:nil];
}
-(void)getOutID{
//获取UserDefaults单例
NSUserDefaults *userDefaults = [NSUserDefaults
standardUserDefaults];
//移除UserDefaults中存储的用户信息
[userDefaults removeObjectForKey:@"name"];
[userDefaults removeObjectForKey:@"MessageNum"];
//[userDefaults removeObjectForKey:@"password"];
[userDefaults synchronize];
[LCProgressHUD
showMessage:@"退出成功"];
}
alertControllerWithTitle:@"提示"
message:@"确定要退出吗?"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction
actionWithTitle:@"取消"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *
_Nonnull action) {
}];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:@"确定"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *
_Nonnull action) {
[LCProgressHUD
showLoading:@"正在退出...."];
[NSTimer
scheduledTimerWithTimeInterval:TIME
target:self
selector:@selector(getOutID)
userInfo:nil
repeats:NO];
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[self
presentViewController:alertController animated:YES
completion:nil];
}
-(void)getOutID{
//获取UserDefaults单例
NSUserDefaults *userDefaults = [NSUserDefaults
standardUserDefaults];
//移除UserDefaults中存储的用户信息
[userDefaults removeObjectForKey:@"name"];
[userDefaults removeObjectForKey:@"MessageNum"];
//[userDefaults removeObjectForKey:@"password"];
[userDefaults synchronize];
[LCProgressHUD
showMessage:@"退出成功"];
}
相关文章推荐
- 出错提示与对策
- WinForm实现自定义右下角提示效果的方法
- PHP错误提示的关闭方法详解
- CSS 动态链接提示
- js实现input密码框提示信息的方法(附html5实现方法)
- extjs 如何给column 加上提示
- JavaScript实现输入框(密码框)出现提示语
- Js制作点击输入框时默认文字消失的效果
- javascript 输入框提示列表效果
- javascript仿百度输入框提示自动下拉补全
- jQuery实现仿QQ头像闪烁效果的文字闪动提示代码
- JQuery实现超链接鼠标提示效果的方法
- 基于jQuery的弹出警告对话框美化插件(警告,确认和提示)
- 老手给学习Linux的新手的建议与提示
- js窗口关闭提示信息(兼容IE和firefox)
- js滑动提示效果代码分享
- Ajax带提示的验证表单实例
- ASP.NET页面某些选项进行提示判断具体实现
- Gridview的链接和删除点击提示的问题探讨
- And,Where使用提示以及用+进行左关联的提示及注意事项