Browse Source

1.修复在Print PDF界面超时登出并显示登录框时Crash。

Pen Li 9 năm trước cách đây
mục cha
commit
4385f41eee

BIN
Ants Contract/AntsContract.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 0 - 34
Ants Contract/AntsContract.xcworkspace/xcuserdata/macmini1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -2,38 +2,4 @@
 <Bucket
    type = "0"
    version = "2.0">
-   <Breakpoints>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            shouldBeEnabled = "No"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "common/ACNetwork.m"
-            timestampString = "513582137.593489"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "760"
-            endingLineNumber = "760"
-            landmarkName = "+heartBeat"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            shouldBeEnabled = "No"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "common/AppDelegate.m"
-            timestampString = "513588311.544328"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "354"
-            endingLineNumber = "354"
-            landmarkName = "-heartBeatRightNow:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-   </Breakpoints>
 </Bucket>

+ 8 - 0
Ants Contract/common/ACNetwork.m

@@ -762,10 +762,18 @@
     [params setObject:@"getStatus" forKey:@"_operate"];
     
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+//    if(appDelegate.user!=nil)
+//        [params setValue:[AESCrypt AES128Encrypt:appDelegate.user  key:@"usai2010"] forKey:@"user"];
+//    if(appDelegate.password!=nil)
+//        [params setValue:[AESCrypt AES128Encrypt:appDelegate.password  key:@"usai2010"] forKey:@"password"];
+    
     if(appDelegate.user!=nil)
         [params setValue:appDelegate.user forKey:@"user"];
     if(appDelegate.password!=nil)
         [params setValue:appDelegate.password forKey:@"password"];
+    
+    
     NSString *DeviceToken = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
     [params setValue:DeviceToken forKey:@"deviceid"];
     

+ 35 - 13
Ants Contract/common/AppDelegate.m

@@ -381,32 +381,54 @@
         
         
         UIApplication *application = [UIApplication sharedApplication];
-        UINavigationController *rootVC = (UINavigationController *)application.keyWindow.rootViewController;
-        
+
         // 超时登出,登出中停止心跳
         [weakself Logout];
+        
+        if (![weakself.window isEqual:application.keyWindow]) {
+            UIWindow *window = application.keyWindow;
+            [window resignKeyWindow];
+            if (window.superview) {
+                [window removeFromSuperview];
+            }
+            window.hidden = YES;
+            window = nil;
+            
+            [self.window makeKeyWindow];
+        }
+        
+        UINavigationController *rootVC = (UINavigationController *)application.keyWindow.rootViewController;
         // 提示登录
         UIViewController* presentVC=rootVC.presentedViewController;
         if (presentVC) { //如果当前已有模态对话框,则关闭当前的模态框
             [presentVC dismissViewControllerAnimated:NO completion:^{
                 // 退回到初始视图
-                [rootVC popToRootViewControllerAnimated:NO];
-                RootViewController* topvc= (RootViewController*)rootVC.topViewController;
-                [topvc dealWithUILogout];
-                dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, 0.25 * NSEC_PER_SEC);
-                dispatch_after(time, dispatch_get_main_queue(), ^{
-                    [topvc presentLogin:topvc.ibSignin];
-                });
+//                [rootVC popToRootViewControllerAnimated:NO];
+//                RootViewController* topvc= (RootViewController*)rootVC.topViewController;
+//                [topvc dealWithUILogout];
+//                // viewDidAppear会自动Present
+////                dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, 0.25 * NSEC_PER_SEC);
+////                dispatch_after(time, dispatch_get_main_queue(), ^{
+////                    [topvc presentLogin:topvc.ibSignin];
+////                });
+                
+                // 递归解决多重Present后,dimiss不完全。
+                [weakself heartBeatTimeout];
+                
             }];
+            
         } else {
-            // 退回到初始视图
-            [rootVC popToRootViewControllerAnimated:NO];
+            if (rootVC.viewControllers.count > 1) {
+                // 退回到初始视图
+                [rootVC popToRootViewControllerAnimated:NO];
+            }
             RootViewController* topvc= (RootViewController*)rootVC.topViewController;
             [topvc dealWithUILogout];
             dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, 0.25 * NSEC_PER_SEC);
             dispatch_after(time, dispatch_get_main_queue(), ^{
                 [topvc presentLogin:topvc.ibSignin];
             });
+            
         }
         
         
@@ -425,13 +447,13 @@
             // 心跳成功才处理计时
             [self markHeartBeatTime];
             
-        } else if (result == 4) { // 超时
+        } else if (result == 4) { // 心跳超时
             
             [weakself heartBeatTimeout];
             
             
         } else if ([weakself checkHearBeatTimeOut]) {// 本地检查超时(上一次成功心跳距现在的间隔时间超出1h)
-            
+        
             [weakself heartBeatTimeout];
         }
         

+ 9 - 5
Ants Contract/common/RootViewController.m

@@ -20,7 +20,7 @@
 
 @interface RootViewController ()
 
-@property (nonatomic,assign) BOOL hasShowLoginVC;
+@property (nonatomic,assign) BOOL hasShowLoginView;
 
 @end
 
@@ -57,8 +57,10 @@
 }
 -(void) presentLogin:(id)sender
 {
-    if (self.hasShowLoginVC) return;
-        
+    // 确保只Presnet LoginView一次.
+    if (self.hasShowLoginView) return;
+    self.hasShowLoginView = YES;
+    
     UIBarButtonItem* bbitem = sender;
     
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
@@ -67,7 +69,9 @@
         loginvc.returnValue = ^(bool blogin){
             
             //            [self checklogin :true];
-            self.hasShowLoginVC = NO;
+            
+            self.hasShowLoginView = NO;
+            
             if(blogin)
             {
                 
@@ -141,7 +145,7 @@
         [self presentViewController:navi animated:YES completion:^{
             
             DebugLog(@"login present.........");
-            self.hasShowLoginVC = YES;
+            
         }];
     }
 }