Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added initializer for setting alert view style easier #4

Merged
merged 1 commit into from
Jan 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions UIAlertView+Blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ typedef void (^UIAlertViewCompletionBlock) (UIAlertView *alertView, NSInteger bu

@interface UIAlertView (Blocks)

+ (void)showWithTitle:(NSString *)title
message:(NSString *)message
style :(UIAlertViewStyle) style
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
tapBlock:(UIAlertViewCompletionBlock)tapBlock;

+ (void)showWithTitle:(NSString *)title
message:(NSString *)message
cancelButtonTitle:(NSString *)cancelButtonTitle
Expand Down
20 changes: 20 additions & 0 deletions UIAlertView+Blocks.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ @implementation UIAlertView (Blocks)

+ (void)showWithTitle:(NSString *)title
message:(NSString *)message
style :(UIAlertViewStyle) style
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
tapBlock:(UIAlertViewCompletionBlock)tapBlock {
Expand All @@ -34,6 +35,8 @@ + (void)showWithTitle:(NSString *)title
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:nil];

alertView.alertViewStyle = style;

for (NSString *buttonTitle in otherButtonTitles) {
[alertView addButtonWithTitle:buttonTitle];
}
Expand All @@ -46,6 +49,23 @@ + (void)showWithTitle:(NSString *)title
#if !__has_feature(objc_arc)
[alertView release];
#endif

}


+ (void)showWithTitle:(NSString *)title
message:(NSString *)message
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
tapBlock:(UIAlertViewCompletionBlock)tapBlock {

[self showWithTitle:title
message:message
style:UIAlertViewStyleDefault
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:otherButtonTitles
tapBlock:tapBlock];

}

#pragma mark -
Expand Down