From 1cfc5bd94fc6c9f31c91f2ad619e03de41c5aa99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Thu, 26 May 2022 20:24:05 +0200 Subject: [PATCH] fix crash when deleting files on iPad --- Mini vMac/InsertDiskViewController.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Mini vMac/InsertDiskViewController.m b/Mini vMac/InsertDiskViewController.m index a510848..590e5f3 100644 --- a/Mini vMac/InsertDiskViewController.m +++ b/Mini vMac/InsertDiskViewController.m @@ -215,7 +215,7 @@ if (editingStyle == UITableViewCellEditingStyleDelete) { NSString *filePath = [self fileAtIndexPath:indexPath]; if ([UIAlertController class]) { - [self askDeleteFile:filePath]; + [self askDeleteFile:filePath sourceView:[tableView cellForRowAtIndexPath:indexPath]]; } else { [self deleteFile:filePath]; } @@ -323,7 +323,7 @@ } } -- (void)askDeleteFile:(NSString*)filePath { +- (void)askDeleteFile:(NSString*)filePath sourceView:(UIView*)sourceView { NSString *fileName = filePath.lastPathComponent; NSString *message = [NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete %@? This operation cannot be undone.", nil), fileName]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Delete File", nil) message:message preferredStyle:UIAlertControllerStyleActionSheet]; @@ -331,6 +331,7 @@ [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Delete", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [self deleteFile:filePath]; }]]; + alertController.popoverPresentationController.sourceView = sourceView; [self presentViewController:alertController animated:YES completion:nil]; } @@ -696,7 +697,7 @@ } - (void)delete:(id)sender { - [self.controller askDeleteFile:self.filePath]; + [self.controller askDeleteFile:self.filePath sourceView:self]; } @end