Skip to content

Instantly share code, notes, and snippets.

@Appletone
Forked from yume190/alertController.m
Created June 27, 2014 04:19

Revisions

  1. @yume190 yume190 revised this gist Jun 19, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions alertController.m
    Original file line number Diff line number Diff line change
    @@ -2,17 +2,17 @@
    UIAlertController* __weak weakAlert = changeAlert;

    UIAlertAction *alertActionOk = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
    [weakAlert dismissViewControllerAnimated:YES completion:nil];
    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) {
    [weakAlert dismissViewControllerAnimated:YES completion:nil];
    UITextField *t = [[weakAlert textFields] firstObject];
    DLog(@"%@",t.text);
    [weakAlert dismissViewControllerAnimated:YES completion:nil];
    }];

    [weakAlert addAction:alertActionOk];
  2. @yume190 yume190 renamed this gist Jun 19, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @yume190 yume190 renamed this gist Jun 19, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @yume190 yume190 created this gist Jun 19, 2014.
    26 changes: 26 additions & 0 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    changeAlert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertController* __weak weakAlert = changeAlert;

    UIAlertAction *alertActionOk = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
    [weakAlert dismissViewControllerAnimated:YES completion:nil];
    UITextField *t = [[weakAlert textFields] firstObject];
    DLog(@"%@",t.text);
    }];
    UIAlertAction *alertActionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
    DLog(@"%@",action);
    }];
    UIAlertAction *alertActionTest = [UIAlertAction actionWithTitle:@"Test" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    [weakAlert dismissViewControllerAnimated:YES completion:nil];
    UITextField *t = [[weakAlert textFields] firstObject];
    DLog(@"%@",t.text);
    }];

    [weakAlert addAction:alertActionOk];
    [weakAlert addAction:alertActionCancel];
    [weakAlert addAction:alertActionTest];

    [weakAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.placeholder = @"pls";
    }];

    [self.viewController presentViewController:weakAlert animated:YES completion:nil]