您的位置:首页 > 产品设计 > UI/UE

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:@"退出成功"];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息