Make the plus button not crash on iPad

This commit is contained in:
David Baker
2014-11-09 23:07:59 +00:00
parent 46d0433a60
commit 9ab5b45a7f
3 changed files with 6 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ typedef void (^blockCustomAlert_onClick)(CustomAlert *alert);
typedef void (^blockCustomAlert_textFieldHandler)(UITextField *textField);
@property(nonatomic) NSInteger cancelButtonIndex; // required to dismiss cusmtomAlert on iOS < 8 (default is -1).
@property(nonatomic, weak) UIView *sourceView;
- (id)initWithTitle:(NSString *)title message:(NSString *)message style:(CustomAlertStyle)style;
// adds a button with the title. returns the index (0 based) of where it was added.

View File

@@ -133,6 +133,10 @@
if ([alert isKindOfClass:[UIAlertController class]]) {
if (viewController) {
parentViewController = viewController;
if (self.sourceView) {
[alert popoverPresentationController].sourceView = self.sourceView;
[alert popoverPresentationController].sourceRect = self.sourceView.bounds;
}
[viewController presentViewController:(UIAlertController *)alert animated:YES completion:nil];
}
} else if ([alert isKindOfClass:[UIActionSheet class]]) {

View File

@@ -953,6 +953,7 @@ NSString *const kFailedEventId = @"failedEventId";
self.actionMenu.cancelButtonIndex = [self.actionMenu addActionWithTitle:@"Cancel" style:CustomAlertActionStyleDefault handler:^(CustomAlert *alert) {
weakSelf.actionMenu = nil;
}];
weakSelf.actionMenu.sourceView = weakSelf.optionBtn;
[self.actionMenu showInViewController:self];
}
}