Skip to content

Instantly share code, notes, and snippets.

@yume190
Last active August 29, 2015 14:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yume190/6f5e3b3c07bececc56d2 to your computer and use it in GitHub Desktop.
Save yume190/6f5e3b3c07bececc56d2 to your computer and use it in GitHub Desktop.
UIAertController Usage
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