-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
2.3&2.4在demo中无法查看UI层次,在我们的项目中表现为查看层次时Xcode崩溃。
应该是window不能addSubview另一个window,对应出问题代码在 WHDebugToolManager.m 文件中-setDebugWindow 方法的[KDebugCurrentWindow addSubview:self.debugWindow];这一行。
建议修改如下:
- (void)setDebugWindow {
if (self.debugWindow) { return; }
CGFloat debugWindowY = debugTool_iPhoneX() ? 30 : 0;
self.debugWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, debugWindowY, kDebugScreenWidth, kDebugLabelHeight)];
self.debugWindow.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
self.debugWindow.windowLevel = UIWindowLevelAlert;
self.debugWindow.rootViewController = [WHDebugTempVC new];
self.debugWindow.hidden = NO;
//[KDebugCurrentWindow addSubview:self.debugWindow];
// 注册window
if (@available(iOS 13.0, *)) {
for (UIWindowScene *windowScene in [UIApplication sharedApplication].connectedScenes) {
if (windowScene.activationState == UISceneActivationStateForegroundActive) {
self.debugWindow.windowScene = windowScene;
break;
}
}
__weak typeof(self) weakSelf = self;
[[NSNotificationCenter defaultCenter] addObserverForName:UISceneWillConnectNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
UIWindowScene *windowScene = note.object;
if (![windowScene isKindOfClass:[UIWindowScene class]]) { return; }
weakSelf.debugWindow.windowScene = windowScene;
}];
}
}Flum-X and ajunjunandtmac
Metadata
Metadata
Assignees
Labels
No labels