jikaipeng 5 年之前
父节点
当前提交
d67be9147e

二进制
KuDianProject.xcworkspace/xcuserdata/kaipeng.xcuserdatad/UserInterfaceState.xcuserstate


+ 54 - 1
KuDianProject/TOP/Drawer/Control/KDPSetViewController.m

@@ -8,6 +8,7 @@
8 8
 
9 9
 #import "KDPSetViewController.h"
10 10
 #import "KDPPhoneLoginViewController.h"
11
+#import "KDPTabBarVC.h"
11 12
 @interface KDPSetViewController ()<UITableViewDelegate,UITableViewDataSource>
12 13
 {
13 14
     
@@ -121,8 +122,60 @@
121 122
 -(void)exitClickButton
122 123
 {
123 124
     [KDPAccountTool deleteAccount];
124
-     [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:[[UINavigationController alloc]initWithRootViewController:[[KDPPhoneLoginViewController alloc]init]] animated:YES completion:nil];
125
+    
125 126
     [self.navigationController popToRootViewControllerAnimated:YES];
127
+    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:[[UINavigationController alloc]initWithRootViewController:[[KDPPhoneLoginViewController alloc]init]] animated:YES completion:^{
128
+        KDPTabBarVC *tabbar = (KDPTabBarVC *)[UIApplication sharedApplication].keyWindow.rootViewController;
129
+        tabbar.selectedIndex = 0;
130
+    }];
131
+}
132
+
133
+- (UIViewController *)getCurrentVC {
134
+    // Find best view controller
135
+    UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
136
+    return [self findBestViewController:viewController];
137
+}
138
+
139
+-(UIViewController*) findBestViewController:(UIViewController*)vc {
140
+    
141
+    if (vc.presentedViewController) {
142
+        
143
+        // Return presented view controller
144
+        return [self findBestViewController:vc.presentedViewController];
145
+        
146
+    } else if ([vc isKindOfClass:[UISplitViewController class]]) {
147
+        
148
+        // Return right hand side
149
+        UISplitViewController* svc = (UISplitViewController*) vc;
150
+        if (svc.viewControllers.count > 0)
151
+            return [self findBestViewController:svc.viewControllers.lastObject];
152
+        else
153
+            return vc;
154
+        
155
+    } else if ([vc isKindOfClass:[UINavigationController class]]) {
156
+        
157
+        // Return top view
158
+        UINavigationController* svc = (UINavigationController*) vc;
159
+        if (svc.viewControllers.count > 0)
160
+            return [self findBestViewController:svc.topViewController];
161
+        else
162
+            return vc;
163
+        
164
+    } else if ([vc isKindOfClass:[UITabBarController class]]) {
165
+        
166
+        // Return visible view
167
+        UITabBarController* svc = (UITabBarController*) vc;
168
+        if (svc.viewControllers.count > 0)
169
+            return [self findBestViewController:svc.selectedViewController];
170
+        else
171
+            return vc;
172
+        
173
+    } else {
174
+        
175
+        // Unknown view controller type, return last child view controller
176
+        return vc;
177
+        
178
+    }
126 179
 }
127 180
 
128 181
 @end