- // 创建UIAlertControlller对象(设置标题,内容,显示风格为Alert或ActionSheet)
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
message:@"This is an alert."
preferredStyle:UIAlertControllerStyleAlert];
- // 创建UIAlertAction对象(按钮标题、风格为Default,Cancel以及Destructive 、action执行后续动作)
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
// UIAlerController加入Action
[alert addAction:defaultAction];
// 显示Alert对象
[self presentViewController:alert animated:YES completion:nil];