mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-09-27 12:59:00 +00:00
fix crash when deleting files on iPad
This commit is contained in:
parent
aa52115d41
commit
1cfc5bd94f
@ -215,7 +215,7 @@
|
|||||||
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
||||||
NSString *filePath = [self fileAtIndexPath:indexPath];
|
NSString *filePath = [self fileAtIndexPath:indexPath];
|
||||||
if ([UIAlertController class]) {
|
if ([UIAlertController class]) {
|
||||||
[self askDeleteFile:filePath];
|
[self askDeleteFile:filePath sourceView:[tableView cellForRowAtIndexPath:indexPath]];
|
||||||
} else {
|
} else {
|
||||||
[self deleteFile:filePath];
|
[self deleteFile:filePath];
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)askDeleteFile:(NSString*)filePath {
|
- (void)askDeleteFile:(NSString*)filePath sourceView:(UIView*)sourceView {
|
||||||
NSString *fileName = filePath.lastPathComponent;
|
NSString *fileName = filePath.lastPathComponent;
|
||||||
NSString *message = [NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete %@? This operation cannot be undone.", nil), fileName];
|
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];
|
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) {
|
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Delete", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
||||||
[self deleteFile:filePath];
|
[self deleteFile:filePath];
|
||||||
}]];
|
}]];
|
||||||
|
alertController.popoverPresentationController.sourceView = sourceView;
|
||||||
[self presentViewController:alertController animated:YES completion:nil];
|
[self presentViewController:alertController animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,7 +697,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)delete:(id)sender {
|
- (void)delete:(id)sender {
|
||||||
[self.controller askDeleteFile:self.filePath];
|
[self.controller askDeleteFile:self.filePath sourceView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user