Przeglądaj źródła

1.修改iOS Apex Drivers Setting卡顿。

Pen Li 7 lat temu
rodzic
commit
58a5055a5c

+ 4 - 2
Redant Drivers/Apex And Drivers/Home/RAHomeViewController.m

@@ -468,8 +468,10 @@
 }
 }
 
 
 - (void)settingClick:(UIButton *)sender {
 - (void)settingClick:(UIButton *)sender {
-    RASettingViewController *settingVC = [RASettingViewController viewControllerFromStoryboard];
-    [self.navigationController pushViewController:settingVC animated:YES];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        RASettingViewController *settingVC = [RASettingViewController viewControllerFromStoryboard];
+        [self.navigationController pushViewController:settingVC animated:YES];
+    });
 }
 }
 
 
 - (void)availableClick:(UIButton *)sender {
 - (void)availableClick:(UIButton *)sender {

+ 50 - 35
Redant Drivers/Apex And Drivers/Setting/RASettingViewController+TableDelegate.m

@@ -81,43 +81,56 @@
 - (void)cleanDiskCache:(RASettingActionModel *)model {
 - (void)cleanDiskCache:(RASettingActionModel *)model {
     model.active = YES;
     model.active = YES;
     
     
-    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"are you sure to clean cached file" preferredStyle:UIAlertControllerStyleAlert];
-    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        
-        model.active = NO;
-    }];
+    dispatch_async(dispatch_get_main_queue(), ^{
     
     
-    UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"are you sure to clean cached file" preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+            model.active = NO;
+        }];
         
         
-        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
             
             
-            NSFileManager *defaultManager = [NSFileManager defaultManager];
-            NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
-            NSString *imageCacheDir = [cacheDir stringByAppendingPathComponent:@"ImageCache"];
-            if ([defaultManager fileExistsAtPath:imageCacheDir]) {
-                [defaultManager removeItemAtPath:imageCacheDir error:nil];
-            }
-            sleep(1.0);
-            dispatch_async(dispatch_get_main_queue(), ^{
-                model.active = NO;
-                
-                [self showAlert:@"Clean Success"];
+            dispatch_async(dispatch_get_global_queue(0, 0), ^{
+
+                NSFileManager *defaultManager = [NSFileManager defaultManager];
+                NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
+                NSString *imageCacheDir = [cacheDir stringByAppendingPathComponent:@"ImageCache"];
+                if ([defaultManager fileExistsAtPath:imageCacheDir]) {
+                    [defaultManager removeItemAtPath:imageCacheDir error:nil];
+                }
+//                sleep(1.0);
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    model.active = NO;
+//
+//                    [self showAlert:@"Clean Success"];
+//                });
+
+                dispatch_after(dispatch_time(1 * NSEC_PER_SEC, DISPATCH_TIME_NOW), dispatch_get_main_queue(), ^{
+                    model.active = NO;
+
+                    [self showAlert:@"Clean Success"];
+                });
+
             });
             });
-        });
+//
+        }];
         
         
-    }];
-    
-    
-    [alertVC addAction:cancelAction];
-    [alertVC addAction:yesAction];
-    
-    [self presentViewController:alertVC animated:YES completion:nil];
+        
+        [alertVC addAction:cancelAction];
+        [alertVC addAction:yesAction];
+        
+        [self presentViewController:alertVC animated:YES completion:nil];
+        
+    });
 }
 }
 
 
 - (void)changePassword:(RASettingActionModel *)model {
 - (void)changePassword:(RASettingActionModel *)model {
     
     
-    RAChangePasswordViewController *vc = [RAChangePasswordViewController viewControllerFromStoryboard];
-    [self presentViewController:vc animated:YES completion:nil];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        RAChangePasswordViewController *vc = [RAChangePasswordViewController viewControllerFromStoryboard];
+        [self presentViewController:vc animated:YES completion:nil];
+    });
 }
 }
 
 
 #pragma mark - Show Option
 #pragma mark - Show Option
@@ -128,13 +141,15 @@
         return;
         return;
     }
     }
     
     
-    RAOptionViewController *optionVC = [RAOptionViewController optionViewControllerWith:model.options selectedIndex:model.selectedIndex];
-    optionVC.optionTitle = model.title;
-    optionVC.selectBlk = ^(NSInteger index) {
-        [model setSelectedIndex:(int)index];
-    };
-    
-    [self.navigationController pushViewController:optionVC animated:YES];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        RAOptionViewController *optionVC = [RAOptionViewController optionViewControllerWith:model.options selectedIndex:model.selectedIndex];
+        optionVC.optionTitle = model.title;
+        optionVC.selectBlk = ^(NSInteger index) {
+            [model setSelectedIndex:(int)index];
+        };
+        
+        [self.navigationController pushViewController:optionVC animated:YES];
+    });
 }
 }
 
 
 @end
 @end