Last active
August 8, 2018 05:13
-
-
Save airrons/281c845b7c1ef34e154b7220ea68a1b0 to your computer and use it in GitHub Desktop.
[Alert弹窗] This is a fast alert code for objc ! #alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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