Commit 1b927ed3 authored by 汪洋's avatar 汪洋

优化visibleController的获取方式

parent 7e1bb3f5
...@@ -76,6 +76,12 @@ ...@@ -76,6 +76,12 @@
数据接收的服务器API 数据接收的服务器API
*/ */
@property (copy, nonatomic) NSString *serverAPI; @property (copy, nonatomic) NSString *serverAPI;
/**
从主项目获取当前显示的controller
*/
@property (nonatomic, copy) UIViewController * (^getTopController) (void);
#pragma mark - 事件采集 #pragma mark - 事件采集
/** /**
......
...@@ -130,15 +130,7 @@ static NSString *sdkVersion = @"110"; ...@@ -130,15 +130,7 @@ static NSString *sdkVersion = @"110";
} }
- (UIViewController *)visibleController { - (UIViewController *)visibleController {
id target = [UIApplication sharedApplication].keyWindow.rootViewController; id target = self.getTopController();
if ([target isKindOfClass:[UITabBarController class]]) {
UITabBarController *tabbar = (UITabBarController *)target;
UINavigationController *navigationController = (UINavigationController *)tabbar.selectedViewController;
target = navigationController.visibleViewController;
} else if ([target isKindOfClass:[UINavigationController class]]) {
UINavigationController *navigationController = (UINavigationController *)target;
target = navigationController.visibleViewController;
}
if ([target conformsToProtocol:NSProtocolFromString(@"PhobosCustomVisibleController")]) { if ([target conformsToProtocol:NSProtocolFromString(@"PhobosCustomVisibleController")]) {
target = [target performSelector:@selector(phobosVisibleController)]; target = [target performSelector:@selector(phobosVisibleController)];
...@@ -439,7 +431,9 @@ static NSString *sdkVersion = @"110"; ...@@ -439,7 +431,9 @@ static NSString *sdkVersion = @"110";
- (void)sendArray { - (void)sendArray {
NSMutableArray *dataArray = [[WMCacheService sharedInstance] fetchObjectAtDucmentPathWithkey:PhobosTempCacheKey]; NSMutableArray *dataArray = [[WMCacheService sharedInstance] fetchObjectAtDucmentPathWithkey:PhobosTempCacheKey];
if (_logEnabled) { if (_logEnabled) {
phobosLog([NSString stringWithFormat:@"array prepare to fly --✈: %@",dataArray]); NSData *data = [NSJSONSerialization dataWithJSONObject:dataArray options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
phobosLog([NSString stringWithFormat:@"array prepare to fly --✈: %@", jsonString]);
} }
@try { @try {
NSData *JSON = [PhobosUtil encodeJSON:dataArray]; NSData *JSON = [PhobosUtil encodeJSON:dataArray];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment