xcode已经提示UIAlertView这个类过时了,ios官网建议使用UIAlertController来开发ios弹出窗口,下面是UIAlertController类的使用案例,如下。
//删除当前用户聊天记录,不影响其他用户
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确定要删除聊天记录吗?" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
//点击确认处理业务
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//清除当前用户聊天记录
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[SinforData sharedData] deleteCurrentUserMsg];
});
}];
[alert addAction:cancelAction];
[alert addAction:confirmAction];
//弹出窗口
[self presentViewController:alert animated:YES completion:nil];