Skip to content

Commit c92e1ea

Browse files
Roc.TianRoc.Tian
Roc.Tian
authored and
Roc.Tian
committedJun 25, 2018
优化顶级窗口弹出
1 parent bb76d5a commit c92e1ea

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎TPFDebugTool/Classes/JxbDebugTool.m

+15-3
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,27 @@ - (void)showDebug {
113113

114114
self.debugVC.viewControllers = @[nav1,nav2,nav3];
115115
UIViewController* vc = [[[UIApplication sharedApplication].delegate window] rootViewController];
116-
UIViewController* vc2 = vc.presentedViewController;
117-
[vc2?:vc presentViewController:self.debugVC animated:YES completion:nil];
116+
UIViewController* vc2 = [self getVisibleViewControllerFrom:vc];
117+
[vc2 presentViewController:self.debugVC animated:YES completion:nil];
118118
}
119119
else {
120120
[self.debugVC dismissViewControllerAnimated:YES completion:nil];
121121
self.debugVC = nil;
122122
}
123123
}
124-
124+
-(UIViewController *) getVisibleViewControllerFrom:(UIViewController *) vc {
125+
if ([vc isKindOfClass:[UINavigationController class]]) {
126+
return [self getVisibleViewControllerFrom:[((UINavigationController *) vc) visibleViewController]];
127+
} else if ([vc isKindOfClass:[UITabBarController class]]) {
128+
return [self getVisibleViewControllerFrom:[((UITabBarController *) vc) selectedViewController]];
129+
} else {
130+
if (vc.presentedViewController) {
131+
return [self getVisibleViewControllerFrom:vc.presentedViewController];
132+
} else {
133+
return vc;
134+
}
135+
}
136+
}
125137
- (void)timerMonitor {
126138
unsigned long long used = [JxbMemoryHelper bytesOfUsedMemory];
127139
NSString* text = [self number2String:used];

0 commit comments

Comments
 (0)
Please sign in to comment.