Просмотр исходного кода

VLCLibraryViewController: fix runtime exception on iOS 7

(cherry picked from commit ed6b1022d223528563b92aa7df92b94e96b83263)
Felix Paul Kühne 7 лет назад
Родитель
Сommit
447a646258
1 измененных файлов с 14 добавлено и 4 удалено
  1. 14 4
      Sources/VLCLibraryViewController.m

+ 14 - 4
Sources/VLCLibraryViewController.m

@@ -1114,11 +1114,21 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
     NSArray *indexPaths = [self usingTableViewToShowData] ? [self.tableView indexPathsForSelectedRows] : [self.collectionView indexPathsForSelectedItems];
 
     if ((!indexPaths || [indexPaths count] == 0) && !_deleteFromTableView) {
-        UIAlertController *invalidSelection = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DELETE_INVALID_TITLE", nil) message:NSLocalizedString(@"DELETE_INVALID_MESSAGE", nil) preferredStyle:UIAlertControllerStyleAlert];
-        UIAlertAction *doneAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_OK", nil) style:UIAlertActionStyleDefault handler:nil];
+        if ([UIAlertController class]) {
+            UIAlertController *invalidSelection = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DELETE_INVALID_TITLE", nil) message:NSLocalizedString(@"DELETE_INVALID_MESSAGE", nil) preferredStyle:UIAlertControllerStyleAlert];
+            UIAlertAction *doneAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_OK", nil) style:UIAlertActionStyleDefault handler:nil];
 
-        [invalidSelection addAction:doneAction];
-        [self presentViewController:invalidSelection animated:YES completion:nil];
+            [invalidSelection addAction:doneAction];
+            [self presentViewController:invalidSelection animated:YES completion:nil];
+        } else {
+            //TODO remove when we drop iOS7
+            VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DELETE_INVALID_TITLE", nil)
+                                                              message:NSLocalizedString(@"DELETE_INVALID_MESSAGE", nil)
+                                                    cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil)
+                                                    otherButtonTitles:nil];
+            alert.completion = nil;
+            [alert show];
+        }
     } else {
         UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DELETE_TITLE", nil) message:nil preferredStyle:UIAlertControllerStyleActionSheet];
         UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_DELETE", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {