Skip to content

Commit 1cfc5bd

Browse files
committed
fix crash when deleting files on iPad
1 parent aa52115 commit 1cfc5bd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Mini vMac/InsertDiskViewController.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
215215
if (editingStyle == UITableViewCellEditingStyleDelete) {
216216
NSString *filePath = [self fileAtIndexPath:indexPath];
217217
if ([UIAlertController class]) {
218-
[self askDeleteFile:filePath];
218+
[self askDeleteFile:filePath sourceView:[tableView cellForRowAtIndexPath:indexPath]];
219219
} else {
220220
[self deleteFile:filePath];
221221
}
@@ -323,14 +323,15 @@ - (void)deleteFile:(NSString*)filePath {
323323
}
324324
}
325325

326-
- (void)askDeleteFile:(NSString*)filePath {
326+
- (void)askDeleteFile:(NSString*)filePath sourceView:(UIView*)sourceView {
327327
NSString *fileName = filePath.lastPathComponent;
328328
NSString *message = [NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete %@? This operation cannot be undone.", nil), fileName];
329329
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Delete File", nil) message:message preferredStyle:UIAlertControllerStyleActionSheet];
330330
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil]];
331331
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Delete", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
332332
[self deleteFile:filePath];
333333
}]];
334+
alertController.popoverPresentationController.sourceView = sourceView;
334335
[self presentViewController:alertController animated:YES completion:nil];
335336
}
336337

@@ -696,7 +697,7 @@ - (void)rename:(id)sender {
696697
}
697698

698699
- (void)delete:(id)sender {
699-
[self.controller askDeleteFile:self.filePath];
700+
[self.controller askDeleteFile:self.filePath sourceView:self];
700701
}
701702

702703
@end

0 commit comments

Comments
 (0)