未验证 提交 32717582 编写于 作者: Y yixiangboy 提交者: GitHub

Merge pull request #259 from DeveloperLY/master

fix: 组件检查或者对齐标尺组件打开后切换rootviewcontroller后失去响应
......@@ -9,6 +9,8 @@
#import "DoraemonDefine.h"
#import "DoraemonViewAlignView.h"
#define kDelegateWindow [[UIApplication sharedApplication].delegate window]
@interface DoraemonViewAlignManager()
@property (nonatomic, strong) DoraemonViewAlignView *alignView;
......@@ -30,18 +32,21 @@
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closePlugin:) name:DoraemonClosePluginNotification object:nil];
[kDelegateWindow addObserver:self forKeyPath:@"rootViewController" options:NSKeyValueObservingOptionNew context:nil];
}
return self;
}
- (void)dealloc {
[kDelegateWindow removeObserver:self forKeyPath:@"rootViewController"];
}
- (void)show{
if (!_alignView) {
_alignView = [[DoraemonViewAlignView alloc] init];
// _alignView.hidden = YES;
[_alignView hide];
UIWindow *delegateWindow = [[UIApplication sharedApplication].delegate window];
[delegateWindow addSubview:_alignView];
[kDelegateWindow addSubview:_alignView];
}
// _alignView.hidden = NO;
[_alignView show];
......@@ -57,4 +62,8 @@
[self hidden];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
[kDelegateWindow bringSubviewToFront:self.alignView];
}
@end
......@@ -9,6 +9,8 @@
#import "DoraemonViewCheckView.h"
#import "DoraemonDefine.h"
#define kDelegateWindow [[UIApplication sharedApplication].delegate window]
@interface DoraemonViewCheckManager()
@property (nonatomic, strong) DoraemonViewCheckView *viewCheckView;
......@@ -30,17 +32,20 @@
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closePlugin:) name:DoraemonClosePluginNotification object:nil];
[kDelegateWindow addObserver:self forKeyPath:@"rootViewController" options:NSKeyValueObservingOptionNew context:nil];
}
return self;
}
- (void)dealloc {
[kDelegateWindow removeObserver:self forKeyPath:@"rootViewController"];
}
- (void)show{
if (!_viewCheckView) {
_viewCheckView = [[DoraemonViewCheckView alloc] init];
_viewCheckView.hidden = YES;
UIWindow *delegateWindow = [[UIApplication sharedApplication].delegate window];
[delegateWindow addSubview:_viewCheckView];
[kDelegateWindow addSubview:_viewCheckView];
}
[_viewCheckView show];
[[NSNotificationCenter defaultCenter] postNotificationName:DoraemonShowPluginNotification object:nil userInfo:nil];
......@@ -54,4 +59,8 @@
[self hidden];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
[kDelegateWindow bringSubviewToFront:self.viewCheckView];
}
@end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册