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