Latest 1.1.4
Homepage https://github.com/mangofever/UIAlertViewWithBlock
License MIT
Platforms ios 7.0, requires ARC

UIAlertView category for block expression

Installation

Using cocoapods


pod 'UIAlertViewBlockExtension'

Features

  • Block expression can be used for handling UIAlertView’s clicks.
  • Similar with UIAlertController in iOS 8.0
  • Automatically, use UIAlertController if it is available (checking via [UIAlertController class])

Examples

can add buttons with action of block

UIAlertView *alertView = [UIAlertView alertViewWithTitle:@"title" message:@"message"];

[alertView addButtonWithTitle:@"OK" actionBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
  // do something for OK
}];

[alertView addCancelButtonWithTitle:@"Cancel" actionBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
  // do something for cancel
}];

[alertView show];

can be used with convenient method

1 Button – Just Cancel

[UIAlertView showWithTitle:@"Title" message:@"message" cancelButtonTitle:@"cancel" action:^{
        NSLog(@"cancel");
    }];

2 Buttons – Cancel & OK

[UIAlertView showWithTitle:@"Title" message:@"message" cancelButtonTitle:@"cancel" cancelAction:^{
        NSLog(@"cancel");
    } otherButtonTitle:@"OK" otherButtonAction:^{
        NSLog(@"ok");
    }];

Requirements

  • iOS version 4.0 or later

Latest podspec

{
    "name": "UIAlertViewBlockExtension",
    "version": "1.1.4",
    "license": "MIT",
    "summary": "UIAlertView category for block expression",
    "homepage": "https://github.com/mangofever/UIAlertViewWithBlock",
    "authors": "Mangofever",
    "source": {
        "git": "https://github.com/mangofever/UIAlertViewWithBlock.git",
        "tag": "1.1.4"
    },
    "source_files": "AlertViewExamples/UIAlertViewBlockExtension/*",
    "requires_arc": true,
    "platforms": {
        "ios": "7.0"
    }
}

Pin It on Pinterest

Share This