// 创建弹框控制器
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入团购信息" message:nil preferredStyle:UIAlertControllerStyleAlert];
// 添加按钮
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
// 创建模型
XMGDeal *deal = [[XMGDeal alloc] init];
deal.title = [alert.textFields[0] text];
deal.price = [alert.textFields[1] text];
[self.deals insertObject:deal atIndex:0];
// 刷新数据
[self.tableView reloadData];
}]];
// [alert addAction:[UIAlertAction actionWithTitle:@"不知道" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// NSLog(@"点击了不知道按钮");
// }]];
// [alert addAction:[UIAlertAction actionWithTitle:@"不知道2" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// NSLog(@"点击了不知道2按钮");
// }]];
// 添加文本输入框
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"请输入团购名字";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"请输入团购价格";
}];
// 显示控制器
[self presentViewController:alert animated:YES completion:nil];