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

Convert alerts in file browser/FLEXUtility to UIAlertController

Ryan Olson лет назад: 6
Родитель
Сommit
a58314a825

+ 2 - 8
Classes/GlobalStateExplorers/FileBrowser/FLEXFileBrowserTableViewController.m

@@ -104,12 +104,6 @@
     }
 }
 
-#pragma mark - Misc
-
-- (void)alert:(NSString *)title message:(NSString *)message {
-    [[[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
-}
-
 #pragma mark - FLEXFileBrowserSearchOperationDelegate
 
 - (void)fileBrowserSearchOperationResult:(NSArray<NSString *> *)searchResult size:(uint64_t)size
@@ -218,7 +212,7 @@
     UIImage *image = cell.imageView.image;
 
     if (!stillExists) {
-        [self alert:@"File Not Found" message:@"The file at the specified path no longer exists."];
+        [FLEXUtility alert:@"File Not Found" message:@"The file at the specified path no longer exists." from:self];
         [self reloadDisplayedPaths];
         return;
     }
@@ -231,7 +225,7 @@
     } else {
         NSData *fileData = [NSData dataWithContentsOfFile:fullPath];
         if (!fileData.length) {
-            [self alert:@"Empty File" message:@"No data returned from the file."];
+            [FLEXUtility alert:@"Empty File" message:@"No data returned from the file." from:self];
             return;
         }
 

+ 3 - 5
Classes/Utility/FLEXUtility.m

@@ -413,11 +413,9 @@
 
 + (void)alert:(NSString *)title message:(NSString *)message from:(UIViewController *)viewController
 {
-    [[[UIAlertView alloc] initWithTitle:title
-                                message:message
-                               delegate:nil
-                      cancelButtonTitle:nil
-                      otherButtonTitles:@"Dismiss", nil] show];
+    UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
+    [alert addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:nil]];
+    [viewController presentViewController:alert animated:YES completion:nil];
 }
 
 + (SEL)swizzledSelectorForSelector:(SEL)selector