Skip to content

Commit 5548930

Browse files
committed
Merge pull request #733 from xmartlabs/fix/actionSheet
fixed crash when launching action sheet from iOS 9
2 parents 639235e + b218344 commit 5548930

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

XLForm/XL/Cell/XLFormSelectorCell.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,26 @@ -(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)c
248248
[actionSheet showInView:controller.view];
249249
#else
250250
if ([UIAlertController class]) {
251+
XLFormViewController * formViewController = self.formViewController;
251252
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:self.rowDescriptor.selectorTitle
252253
message:nil
253254
preferredStyle:UIAlertControllerStyleActionSheet];
254255
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
255256
style:UIAlertActionStyleCancel
256257
handler:nil]];
258+
alertController.popoverPresentationController.sourceView = formViewController.tableView;
259+
UIView* v = (self.detailTextLabel ?: self.textLabel) ?: self.contentView;
260+
alertController.popoverPresentationController.sourceRect = [formViewController.tableView convertRect:v.frame fromView:self];
257261
__weak __typeof(self)weakSelf = self;
258262
for (id option in self.rowDescriptor.selectorOptions) {
259263
[alertController addAction:[UIAlertAction actionWithTitle:[option displayText]
260264
style:UIAlertActionStyleDefault
261265
handler:^(UIAlertAction *action) {
262266
[weakSelf.rowDescriptor setValue:option];
263-
[weakSelf.formViewController.tableView reloadData];
267+
[formViewController.tableView reloadData];
264268
}]];
265269
}
266-
[self.formViewController presentViewController:alertController animated:YES completion:nil];
270+
[formViewController presentViewController:alertController animated:YES completion:nil];
267271
}
268272
else{
269273
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:self.rowDescriptor.selectorTitle

0 commit comments

Comments
 (0)