|
@@ -9,6 +9,7 @@
|
9
|
9
|
#import "KDPNetworkRequestHTTP.h"
|
10
|
10
|
#import <AdSupport/AdSupport.h>
|
11
|
11
|
#import "KDPPhoneLoginViewController.h"
|
|
12
|
+#import "KDPTabBarVC.h"
|
12
|
13
|
@implementation KDPNetworkRequestHTTP
|
13
|
14
|
+ (void)postURL:(NSString *)url params:(NSDictionary *)params success:(void(^)(id json))success failure:(void(^)(NSError *error))failure
|
14
|
15
|
{
|
|
@@ -84,9 +85,64 @@
|
84
|
85
|
{
|
85
|
86
|
[[NSNotificationCenter defaultCenter]postNotificationName:@"exitLogin" object:nil];
|
86
|
87
|
[KDPAccountTool deleteAccount];
|
|
88
|
+
|
|
89
|
+ [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:[[UINavigationController alloc]initWithRootViewController:[[KDPPhoneLoginViewController alloc]init]] animated:YES completion:^{
|
|
90
|
+ UIViewController *currentVC = [[self alloc] getCurrentVC];
|
|
91
|
+
|
|
92
|
+ [currentVC.navigationController popToRootViewControllerAnimated:YES];
|
|
93
|
+
|
|
94
|
+ KDPTabBarVC *tabbar = (KDPTabBarVC *)[UIApplication sharedApplication].keyWindow.rootViewController;
|
|
95
|
+ tabbar.selectedIndex = 0;
|
|
96
|
+ }];
|
87
|
97
|
|
88
|
|
- [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:[[UINavigationController alloc]initWithRootViewController:[[KDPPhoneLoginViewController alloc]init]] animated:YES completion:nil];
|
|
98
|
+}
|
|
99
|
+
|
|
100
|
+- (UIViewController *)getCurrentVC {
|
|
101
|
+ // Find best view controller
|
|
102
|
+ UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
|
|
103
|
+ return [self findBestViewController:viewController];
|
|
104
|
+}
|
|
105
|
+
|
|
106
|
+-(UIViewController*) findBestViewController:(UIViewController*)vc {
|
89
|
107
|
|
|
108
|
+ if (vc.presentedViewController) {
|
|
109
|
+
|
|
110
|
+ // Return presented view controller
|
|
111
|
+ return [self findBestViewController:vc.presentedViewController];
|
|
112
|
+
|
|
113
|
+ } else if ([vc isKindOfClass:[UISplitViewController class]]) {
|
|
114
|
+
|
|
115
|
+ // Return right hand side
|
|
116
|
+ UISplitViewController* svc = (UISplitViewController*) vc;
|
|
117
|
+ if (svc.viewControllers.count > 0)
|
|
118
|
+ return [self findBestViewController:svc.viewControllers.lastObject];
|
|
119
|
+ else
|
|
120
|
+ return vc;
|
|
121
|
+
|
|
122
|
+ } else if ([vc isKindOfClass:[UINavigationController class]]) {
|
|
123
|
+
|
|
124
|
+ // Return top view
|
|
125
|
+ UINavigationController* svc = (UINavigationController*) vc;
|
|
126
|
+ if (svc.viewControllers.count > 0)
|
|
127
|
+ return [self findBestViewController:svc.topViewController];
|
|
128
|
+ else
|
|
129
|
+ return vc;
|
|
130
|
+
|
|
131
|
+ } else if ([vc isKindOfClass:[UITabBarController class]]) {
|
|
132
|
+
|
|
133
|
+ // Return visible view
|
|
134
|
+ UITabBarController* svc = (UITabBarController*) vc;
|
|
135
|
+ if (svc.viewControllers.count > 0)
|
|
136
|
+ return [self findBestViewController:svc.selectedViewController];
|
|
137
|
+ else
|
|
138
|
+ return vc;
|
|
139
|
+
|
|
140
|
+ } else {
|
|
141
|
+
|
|
142
|
+ // Unknown view controller type, return last child view controller
|
|
143
|
+ return vc;
|
|
144
|
+
|
|
145
|
+ }
|
90
|
146
|
}
|
91
|
147
|
|
92
|
148
|
/**
|