
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"标题" message:@"2222" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alertView show];
//iOS8以后
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"标题" message:@"2222222" preferredStyle:UIAlertControllerStyleAlert];
//添加按钮
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击了确定");
}]];
//显示控制器
[self presentViewController:alert animated:YES completion:nil];
还可以换种样式:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"标题" message:@"2222222" preferredStyle:UIAlertControllerStyleActionSheet];
//添加按钮
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击了确定");
}]];
//显示控制器
[self presentViewController:alert animated:YES completion:nil];
还可以添加文本输入框:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"标题" message:@"2222222" preferredStyle:UIAlertControllerStyleAlert];
//添加按钮
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
// NSLog(@"点击了确定");
//拿到文本输入框的值
NSString *name = [alert.textFields[0] text];
NSString *pwd = [alert.textFields[1] text];
NSLog(@"%@ %@",name,pwd);
}]];
//还可以添加文本输入框
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"请输入用户名";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"请输入密码";
}];
//显示控制器
[self presentViewController:alert animated:YES completion:nil];