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

Merge pull request #258 from klone1127/master

fix: 性能检测: 帧率、CPU、内存、流量页面打开时关闭悬浮窗后 UISwitch 按钮状态未改变问题
......@@ -6,8 +6,15 @@
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "DoraemonOscillogramViewController.h"
@protocol DoraemonOscillogramWindowDelegate <NSObject>
- (void)doraemonOscillogramWindowClosed;
@end
@interface DoraemonOscillogramWindow : UIWindow
+ (DoraemonOscillogramWindow *)shareInstance;
......@@ -21,4 +28,8 @@
- (void)hide;
- (void)addDelegate:(id<DoraemonOscillogramWindowDelegate>) delegate;
- (void)removeDelegate:(id<DoraemonOscillogramWindowDelegate>)delegate;
@end
......@@ -13,10 +13,27 @@
@interface DoraemonOscillogramWindow()
@property (nonatomic, strong) NSHashTable *delegates;
@end
@implementation DoraemonOscillogramWindow
- (NSHashTable *)delegates {
if (_delegates == nil) {
self.delegates = [NSHashTable weakObjectsHashTable];
}
return _delegates;
}
- (void)addDelegate:(id<DoraemonOscillogramWindowDelegate>) delegate {
[self.delegates addObject:delegate];
}
- (void)removeDelegate:(id<DoraemonOscillogramWindowDelegate>)delegate {
[self.delegates removeObject:delegate];
}
+ (DoraemonOscillogramWindow *)shareInstance{
static dispatch_once_t once;
static DoraemonOscillogramWindow *instance;
......@@ -65,6 +82,10 @@
[_vc endRecord];
self.hidden = YES;
[self resetLayout];
for (id<DoraemonOscillogramWindowDelegate> delegate in self.delegates) {
[delegate doraemonOscillogramWindowClosed];
}
}
- (void)resetLayout{
......
......@@ -13,7 +13,7 @@
#import "DoraemonCellSwitch.h"
#import "DoraemonDefine.h"
@interface DoraemonCPUViewController ()<DoraemonSwitchViewDelegate>
@interface DoraemonCPUViewController ()<DoraemonSwitchViewDelegate, DoraemonOscillogramWindowDelegate>
@property (nonatomic, strong) DoraemonCellSwitch *switchView;
......@@ -31,6 +31,7 @@
[_switchView needDownLine];
_switchView.delegate = self;
[self.view addSubview:_switchView];
[[DoraemonCPUOscillogramWindow shareInstance] addDelegate:self];
}
- (BOOL)needBigTitleView{
......@@ -47,4 +48,9 @@
}
}
#pragma mark -- DoraemonOscillogramWindowDelegate
- (void)doraemonOscillogramWindowClosed {
[_switchView renderUIWithTitle:DoraemonLocalizedString(@"CPU检测开关") switchOn:[[DoraemonCacheManager sharedInstance] cpuSwitch]];
}
@end
......@@ -12,7 +12,7 @@
#import "DoraemonCellSwitch.h"
#import "DoraemonDefine.h"
@interface DoraemonFPSViewController ()<DoraemonSwitchViewDelegate>
@interface DoraemonFPSViewController ()<DoraemonSwitchViewDelegate, DoraemonOscillogramWindowDelegate>
@property (nonatomic, strong) DoraemonCellSwitch *switchView;
......@@ -30,6 +30,7 @@
[_switchView needDownLine];
_switchView.delegate = self;
[self.view addSubview:_switchView];
[[DoraemonFPSOscillogramWindow shareInstance] addDelegate:self];
}
......@@ -48,4 +49,9 @@
}
}
#pragma mark -- DoraemonOscillogramWindowDelegate
- (void)doraemonOscillogramWindowClosed {
[_switchView renderUIWithTitle:DoraemonLocalizedString(@"帧率检测开关") switchOn:[[DoraemonCacheManager sharedInstance] fpsSwitch]];
}
@end
......@@ -12,7 +12,7 @@
#import "DoraemonCellSwitch.h"
#import "DoraemonDefine.h"
@interface DoraemonMemoryViewController ()<DoraemonSwitchViewDelegate>
@interface DoraemonMemoryViewController ()<DoraemonSwitchViewDelegate, DoraemonOscillogramWindowDelegate>
@property (nonatomic, strong) DoraemonCellSwitch *switchView;
......@@ -30,6 +30,7 @@
[_switchView needDownLine];
_switchView.delegate = self;
[self.view addSubview:_switchView];
[[DoraemonMemoryOscillogramWindow shareInstance] addDelegate:self];
}
- (BOOL)needBigTitleView{
......@@ -46,4 +47,9 @@
}
}
#pragma mark -- DoraemonOscillogramWindowDelegate
- (void)doraemonOscillogramWindowClosed {
[_switchView renderUIWithTitle:DoraemonLocalizedString(@"内存检测开关") switchOn:[[DoraemonCacheManager sharedInstance] memorySwitch]];
}
@end
......@@ -21,7 +21,7 @@
#import "DoraemonDefine.h"
@interface DoraemonNetFlowViewController ()<DoraemonSwitchViewDelegate>
@interface DoraemonNetFlowViewController ()<DoraemonSwitchViewDelegate, DoraemonOscillogramWindowDelegate>
@property (nonatomic, strong) UITabBarController *tabBar;
@property (nonatomic, strong) DoraemonCellSwitch *switchView;
......@@ -33,6 +33,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self initUI];
[[DoraemonNetFlowOscillogramWindow shareInstance] addDelegate:self];
}
- (void)initUI{
......@@ -104,4 +105,9 @@
[self presentViewController:tabBar animated:YES completion:nil];
}
#pragma mark -- DoraemonOscillogramWindowDelegate
- (void)doraemonOscillogramWindowClosed {
[_switchView renderUIWithTitle:DoraemonLocalizedString(@"流量检测开关") switchOn:[[DoraemonCacheManager sharedInstance] netFlowSwitch]];
}
@end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册