Latest 0.1.0
Homepage https://github.com/pablosproject/PTAlertView
License MIT
Platforms ios 5.0, requires ARC
Authors

Version
License
Platform

This is a simple category of UIAlertView that simplify the basic usage of alerts with blocks. It uses AssociatedObject to handle delegate’s method.

Usage

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

Example

You could use the category by importing it and instantiate a new alert with the provided initialization method.
This method takes the titles of the confirmation and cancel buttons and a block for every case.
If you not provide a title for the cancel button, the alert will only show the confirmation button.

#import <UIAlertView+Blocks.h>

/*
    Alert with two buttons
*/
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert"
                                                    message:@"This is a test with block"
                                         confirmButtonTitle:@"Ok"
                                         confirmButtonBlock:^{
                                             NSLog(@"Confirmation pressed");
                                         }
                                          cancelButtonTitle:@"Cancel"
                                          cancelButtonBlock:^{
                                              NSLog(@"Cancel pressed");
                                          }];
    [alert show];

/*
    Alert with one button
*/
        UIAlertView *singleAlert = [[UIAlertView alloc] initWithTitle:@"Alert"
                                                    message:@"This is a test with block"
                                         confirmButtonTitle:@"Ok"
                                         confirmButtonBlock:^{
                                             NSLog(@"Confirmation pressed");
                                         }
                                          cancelButtonTitle:nil
                                          cancelButtonBlock:nil];
    [singleAlert show];

}

Installation

PTAlertView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "PTAlertView"

Author

Paolo Tagliani, [email protected]

License

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

Latest podspec

{
    "name": "PTAlertView",
    "version": "0.1.0",
    "summary": "A simple category that add UIAlertView handling with blocks.",
    "homepage": "https://github.com/pablosproject/PTAlertView",
    "license": "MIT",
    "authors": {
        "Paolo Tagliani": "[email protected]"
    },
    "source": {
        "git": "https://github.com/pablosproject/PTAlertView.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/PablosProject",
    "platforms": {
        "ios": "5.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes"
}

Pin It on Pinterest

Share This