Skip to content

Commit

Permalink
查看布局类重写setValue方法等
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenglibao committed Jul 23, 2018
1 parent 21720bd commit 13eb586
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
**FlexLib**的所有版本的变更日志都将会在这里记录.

---

## 1.8.7
1. 重写FlexHttpViewerVC::setValue:forKey:和FlexViewer::setValue:forKey:防止查看xml布局时有内存泄漏
2. FlexRootView的KVO策略调整,只观测UILabel的text和attributeText属性

## 1.8.6
修复监听UITextField导致的泄漏

Expand Down
2 changes: 1 addition & 1 deletion FlexLib.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'FlexLib'
s.version = '1.8.6'
s.version = '1.8.7'
s.summary = 'An obj-c flex layout framework for IOS'

# This description is used to generate tags and improve search results.
Expand Down
7 changes: 7 additions & 0 deletions FlexLib/Classes/FlexHttpVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ @interface FlexHttpViewerVC : FlexBaseVC

@implementation FlexHttpViewerVC

/*
* 重写以防止变量绑定异常导致查看xml时有内存泄漏
*/
- (void)setValue:(id)value forKey:(NSString *)key
{
}

-(void)viewDidLoad{
[super viewDidLoad];

Expand Down
6 changes: 6 additions & 0 deletions FlexLib/Classes/FlexLayoutViewerVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ - (void)viewDidLoad {
[super viewDidLoad];
[self prepareInputs];
}
/*
* 重写以防止变量绑定异常导致查看xml时有内存泄漏
*/
- (void)setValue:(id)value forKey:(NSString *)key
{
}
@end

@interface FlexLayoutViewerVC ()<UITableViewDelegate,UITableViewDataSource>
Expand Down
6 changes: 4 additions & 2 deletions FlexLib/Classes/FlexRootView.m
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ -(void)registSubView:(UIView*)subView
[_observedViews addObject:subView];

[subView addObserver:self forKeyPath:@"hidden" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:gObserverHidden];
if(![subView isKindOfClass:[UITextField class]]){

if([subView isKindOfClass:[UILabel class]]){
[subView addObserver:self forKeyPath:@"text" options:0 context:gObserverText];
[subView addObserver:self forKeyPath:@"attributedText" options:0 context:gObserverAttrText];
}
Expand All @@ -348,7 +349,8 @@ -(void)removeWatchView:(UIView*)view
[_observedViews removeObject:view];

[view removeObserver:self forKeyPath:@"hidden"];
if(![view isKindOfClass:[UITextField class]]){

if([view isKindOfClass:[UILabel class]]){
[view removeObserver:self forKeyPath:@"text"];
[view removeObserver:self forKeyPath:@"attributedText"];
}
Expand Down

0 comments on commit 13eb586

Please sign in to comment.