ARNAlert 0.2.2

ARNAlert 0.2.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Sep 2015

Maintained by airin.



ARNAlert 0.2.2

  • By
  • Airin

Wrapper of UIAlertView & UIAlertController.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Show No Action Alert

[ARNAlert showNoActionAlertWithTitle:@"no action title" message:@"no action message" buttonTitle:@"No Acttion"];

// iOS8 : UIAlertController addAction(UIAlertActionStyleCancel)
// iOS7 : UIAlertView clickedButtonAtIndex(cancelButtonIndex)

Show Simple Action Alert

[ARNAlert showAlertWithTitle:@"test Title"
                     message:@"test Message"
           cancelButtonTitle:@"Cancel"
                 cancelBlock:^(id action){
                     NSLog(@"cancelBlock call!");

                     // iOS8 : UIAlertController addAction(UIAlertActionStyleCancel)
                     // iOS7 : UIAlertView clickedButtonAtIndex(cancelButtonIndex)
                 }
               okButtonTitle:@"OK"
                     okBlock:^(id action){
                     NSLog(@"okBlock call!");

                     // iOS8 : UIAlertController addAction(UIAlertActionStyleDefault)
                     // iOS7 : UIAlertView clickedButtonAtIndex(buttonIndex)
}];

Show Some Action Alert

ARNAlert *alert = [[ARNAlert alloc] initWithTitle:@"test Title" message:@"test Message"];
[alert addActionTitle:@"button" actionBlock:^(id action) {
    NSLog(@"button Button tapped!");

    // iOS8 : UIAlertController addAction(UIAlertActionStyleDefault)
    // iOS7 : UIAlertView clickedButtonAtIndex(buttonIndex)
}];
[alert setCancelTitle:@"cancel" cancelBlock:^(id action) {
    NSLog(@"cancel Button tapped!");

    // iOS8 : UIAlertController addAction(UIAlertActionStyleCancel)
    // iOS7 : UIAlertView  clickedButtonAtIndex(cancelButtonIndex)
}];
[alert show];

Show Some Textfield Alert

    ARNAlert *alert = [[ARNAlert alloc] initWithTitle:@"test Text " message:@"test Message"];

    [alert addTextFieldWithPlaceholder:@"place1" fillInText:@"tex1"];
    [alert addTextFieldWithPlaceholder:@"place2" fillInText:@"tex2"];
    // iOS7 is Nothing
    [alert addTextFieldWithPlaceholder:@"place3" fillInText:@"tex3"];

    [alert addActionTitle:@"button1"
              actionBlock:^(NSArray *texitFields) {
                  NSLog(@"button1 tapped!");
                  NSLog(@"texitFields : %@", texitFields);
                  for (int i = 0; i < texitFields.count; ++i) {
                      UITextField *textField = texitFields[i];
                      NSLog(@"texitField.text : %@", textField.text);
                  }
              }];
    [alert addActionTitle:@"button2"
              actionBlock:^(NSArray *texitFields) {
                  NSLog(@"button2 tapped!");
                  NSLog(@"texitFields : %@", texitFields);
                  for (int i = 0; i < texitFields.count; ++i) {
                      UITextField *textField = texitFields[i];
                      NSLog(@"texitField.text : %@", textField.text);
                  }
              }];
    [alert setCancelTitle:@"Cancel"
              cancelBlock:^(NSArray *texitFields) {
                  NSLog(@"cancel Button tapped!");
                  NSLog(@"texitFields : %@", texitFields);
                  for (int i = 0; i < texitFields.count; ++i) {
                      UITextField *textField = texitFields[i];
                      NSLog(@"texitField.text : %@", textField.text);
                  }
              }];

    [alert show];

Requirements

  • iOS 7.0+
  • ARC

Installation

License

ARNAlert is available under the MIT license. See the LICENSE file for more info.