forked from jivadevoe/UIAlertView-Blocks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
UIAlertView+Blocks.h
56 lines (40 loc) · 1.72 KB
/
UIAlertView+Blocks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// UIAlertView+Blocks.h
// Shibui
//
// Created by Jiva DeVoe on 12/28/10.
// Copyright 2010 Random Ideas, LLC. All rights reserved.
// Modified by Robert Saunders on 20/01/12
//
#import <Foundation/Foundation.h>
@interface UIAlertView (Blocks)
/*
This method only work if you want a one or two button alert view.
This should do for 90% of use cases, if you need more button use the standard constructor.
For a one button alert provide nil for both the right button title and action
This method will create and display the alert and automatically invoke the given block
when the button is tapped.
Example usage:
[UIAlertView displayAlertWithTitle:@"Example Alert View With Blocks"
message:@"What is the meaning of life?"
leftButtonTitle:@"41"
leftButtonAction:^{
NSLog(@"Incorrect");
}
rightButtonTitle:@"42"
rightButtonAction:^{
[UIAlertView displayAlertWithTitle:@"Result"
message:@"You chose wisely"
leftButtonTitle:@"Ok"
leftButtonAction:nil
rightButtonTitle:nil
rightButtonAction:nil];
}];
*/
+ (void) displayAlertWithTitle:(NSString *)title
message:(NSString *)message
leftButtonTitle:(NSString *)leftButtonTitle
leftButtonAction:(void (^)(void))leftButtonAction
rightButtonTitle:(NSString*)rightButtonTitle
rightButtonAction:(void (^)(void))rightButtonAction;
@end