https://github.com/pablosproject/ptalertview
A simple category that add basic alert view management using blocks.
https://github.com/pablosproject/ptalertview
Last synced: about 1 month ago
JSON representation
A simple category that add basic alert view management using blocks.
- Host: GitHub
- URL: https://github.com/pablosproject/ptalertview
- Owner: pablosproject
- License: mit
- Created: 2014-09-29T20:40:37.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-30T09:26:54.000Z (over 11 years ago)
- Last Synced: 2025-02-21T11:53:10.615Z (over 1 year ago)
- Language: Objective-C
- Size: 215 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PTAlertView
[](http://cocoadocs.org/docsets/PTAlertView)
[](http://cocoadocs.org/docsets/PTAlertView)
[](http://cocoadocs.org/docsets/PTAlertView)
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.
```objective-c
#import
/*
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](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
pod "PTAlertView"
## Author
Paolo Tagliani, pablosproject@gmail.com
## License
PTAlertView is available under the MIT license. See the LICENSE file for more info.