Inherits from UIAlertView
Declared in KVAlertView.h
KVAlertView.m

Overview

This subclass of UIAlertView adds support for blocks.

Sample usage:

KVAlertView *alert = [KVAlertView alertWithTitle:NSLocalizedString(@"Title", @"")
                                         message:NSLocalizedString(@"Message", @"")
                               cancelButtonTitle:NSLocalizedString(@"Cancel", @"")
                                     cancelBlock:^(KVAlertView *alertView){
                                                     NSLog(@"Cancel");
                                                 }];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert addButtonWithTitle:NSLocalizedString(@"OK", @"") block:^(KVAlertView *alertView){
    NSLog(@"OK: %@", [alertView textFieldAtIndex:0].text);
}];
[alert show];

Class Methods

alertWithTitle:message:cancelButtonTitle:cancelBlock:

Create an alert

+ (KVAlertView *)alertWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle cancelBlock:(KVAlertViewBlock)cancelBlock

Parameters

title

Title in alert

message

Message in alert

cancelButtonTitle

Title of Cancel button in alert

cancelBlock

Block to execute when Cancel button is pressed

Return Value

Instance of KVAlertView

Discussion

Create an alert

Declared In

KVAlertView.h

alertWithTitle:message:cancelButtonTitle:cancelBlock:confirmButtonTitle:confirmBlock:

Create an alert

+ (KVAlertView *)alertWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle cancelBlock:(KVAlertViewBlock)cancelBlock confirmButtonTitle:(NSString *)confirmButtonTitle confirmBlock:(KVAlertViewBlock)confirmBlock

Parameters

title

Title in alert

message

Message in alert

cancelButtonTitle

Title of Cancel button in alert

cancelBlock

Block to execute when Cancel button is pressed

confirmButtonTitle

Title of Confirm (OK) button in alert

confirmBlock

Block to execute when Confirm button is pressed

Return Value

Instance of KVAlertView

Discussion

Create an alert

Declared In

KVAlertView.h

showWithTitle:message:cancelButtonTitle:cancelBlock:

Create and immediately show an alert

+ (void)showWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle cancelBlock:(KVAlertViewBlock)cancelBlock

Parameters

title

Title in alert

message

Message in alert

cancelButtonTitle

Title of Cancel button in alert

cancelBlock

Block to execute when Cancel button is pressed

Discussion

Create and immediately show an alert

Declared In

KVAlertView.h

showWithTitle:message:cancelButtonTitle:cancelBlock:confirmButtonTitle:confirmBlock:

Create and immediately show an alert

+ (void)showWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle cancelBlock:(KVAlertViewBlock)cancelBlock confirmButtonTitle:(NSString *)confirmButtonTitle confirmBlock:(KVAlertViewBlock)confirmBlock

Parameters

title

Title in alert

message

Message in alert

cancelButtonTitle

Title of Cancel button in alert

cancelBlock

Block to execute when Cancel button is pressed

confirmButtonTitle

Title of Confirm (OK) button in alert

confirmBlock

Block to execute when Confirm button is pressed

Discussion

Create and immediately show an alert

Declared In

KVAlertView.h

Instance Methods

addButtonWithTitle:block:

Add a button to the alert

- (NSInteger)addButtonWithTitle:(NSString *)title block:(KVAlertViewBlock)block

Parameters

title

Title of button

block

Block to execute when button is pressed

Return Value

Index of added button

Discussion

Add a button to the alert

Declared In

KVAlertView.h