Skip to content

Commit 40a203f

Browse files
committed
move cancel/dissmiss to first left button
1 parent 6fec176 commit 40a203f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

BlocksKit/UIKit/UIAlertView+BlocksKit.m

+15-7
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ + (void)load {
120120
+ (void) showAlertViewWithTitle: (NSString *) title message: (NSString *) message cancelButtonTitle: (NSString *) cancelButtonTitle otherButtonTitles: (NSArray *) otherButtonTitles handler: (void (^)(UIAlertView *, NSInteger)) block
121121
{
122122
UIAlertView *alertView = [[self class] alertViewWithTitle: title message: message];
123+
124+
// If no buttons were specified, cancel button becomes "Dismiss"
125+
if (!cancelButtonTitle.length && !otherButtonTitles.count)
126+
cancelButtonTitle = NSLocalizedString(@"Dismiss", nil);
127+
128+
// Set cancel button
129+
if (cancelButtonTitle.length)
130+
alertView.cancelButtonIndex = [alertView addButtonWithTitle: cancelButtonTitle];
123131

124132
// Set other buttons
125133
if (otherButtonTitles.count)
@@ -133,13 +141,13 @@ + (void) showAlertViewWithTitle: (NSString *) title message: (NSString *) messag
133141
}];
134142
}
135143

136-
// If no buttons were specified, cancel button becomes "Dismiss"
137-
if (!cancelButtonTitle.length && !otherButtonTitles.count)
138-
cancelButtonTitle = NSLocalizedString(@"Dismiss", nil);
139-
140-
// Set cancel button
141-
if (cancelButtonTitle.length)
142-
alertView.cancelButtonIndex = [alertView addButtonWithTitle: cancelButtonTitle];
144+
// // If no buttons were specified, cancel button becomes "Dismiss"
145+
// if (!cancelButtonTitle.length && !otherButtonTitles.count)
146+
// cancelButtonTitle = NSLocalizedString(@"Dismiss", nil);
147+
//
148+
// // Set cancel button
149+
// if (cancelButtonTitle.length)
150+
// alertView.cancelButtonIndex = [alertView addButtonWithTitle: cancelButtonTitle];
143151

144152
// Set `didDismissBlock`
145153
if (block) alertView.didDismissBlock = block;

0 commit comments

Comments
 (0)