Skip to content

Instantly share code, notes, and snippets.

@airrons
Last active August 8, 2018 05:13
Show Gist options
  • Save airrons/281c845b7c1ef34e154b7220ea68a1b0 to your computer and use it in GitHub Desktop.
Save airrons/281c845b7c1ef34e154b7220ea68a1b0 to your computer and use it in GitHub Desktop.
[Alert弹窗] This is a fast alert code for objc ! #alert
// vim: syntax=objective-c
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"提示" message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction * okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
UITextField * textField = [alertController textFields].firstObject;
if (![textField.text isEqualToString:@"新建文件"] && textField.text.length > 0) {
}
}];
[alertController addAction:okAction];
[alertController addAction:cancelAction];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"新建文件";
}];
[self presentViewController:alertController animated:YES completion:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment