Skip to content

Instantly share code, notes, and snippets.

@Appletone
Forked from yume190/alertController.m
Created June 27, 2014 04:19
Show Gist options
  • Save Appletone/6b44418562cd16f0f53c to your computer and use it in GitHub Desktop.
Save Appletone/6b44418562cd16f0f53c to your computer and use it in GitHub Desktop.
changeAlert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertController* __weak weakAlert = changeAlert;
UIAlertAction *alertActionOk = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
UITextField *t = [[weakAlert textFields] firstObject];
DLog(@"%@",t.text);
[weakAlert dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction *alertActionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
DLog(@"%@",action);
}];
UIAlertAction *alertActionTest = [UIAlertAction actionWithTitle:@"Test" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
UITextField *t = [[weakAlert textFields] firstObject];
DLog(@"%@",t.text);
[weakAlert dismissViewControllerAnimated:YES completion:nil];
}];
[weakAlert addAction:alertActionOk];
[weakAlert addAction:alertActionCancel];
[weakAlert addAction:alertActionTest];
[weakAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"pls";
}];
[self.viewController presentViewController:weakAlert animated:YES completion:nil]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment