Skip to content

Commit

Permalink
#fix NNFadeAnimationImageView 释放问题
Browse files Browse the repository at this point in the history
  • Loading branch information
amisare committed Jul 19, 2019
1 parent 8860442 commit 270ae15
Show file tree
Hide file tree
Showing 6 changed files with 386 additions and 313 deletions.
9 changes: 9 additions & 0 deletions NNNavigationBar/NNNavigationBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
676D498920AE907A0016ADBA /* NNNavigationBarBackgroundImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 676D498720AE907A0016ADBA /* NNNavigationBarBackgroundImage.m */; };
676D498C20AE92BB0016ADBA /* NNNavigationBarBackgroundAlpha.h in Headers */ = {isa = PBXBuildFile; fileRef = 676D498A20AE92BB0016ADBA /* NNNavigationBarBackgroundAlpha.h */; settings = {ATTRIBUTES = (Public, ); }; };
676D499020AE93420016ADBA /* NNNavigationBarTintColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 676D498E20AE93420016ADBA /* NNNavigationBarTintColor.h */; settings = {ATTRIBUTES = (Public, ); }; };
677CB32D22E1B52F001FA15C /* NNProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 677CB32B22E1B52F001FA15C /* NNProxy.h */; };
677CB32E22E1B52F001FA15C /* NNProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 677CB32C22E1B52F001FA15C /* NNProxy.m */; };
67E456A920A0073A00E58475 /* NNNavigationBar.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 67E4569F20A0073A00E58475 /* NNNavigationBar.framework */; };
67E456AE20A0073A00E58475 /* NNNavigationBarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 67E456AD20A0073A00E58475 /* NNNavigationBarTests.m */; };
67E456F420A007C200E58475 /* UINavigationBar+NNBackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 67E456BB20A007C200E58475 /* UINavigationBar+NNBackgroundView.m */; };
Expand Down Expand Up @@ -77,6 +79,8 @@
676D498720AE907A0016ADBA /* NNNavigationBarBackgroundImage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NNNavigationBarBackgroundImage.m; sourceTree = "<group>"; };
676D498A20AE92BB0016ADBA /* NNNavigationBarBackgroundAlpha.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NNNavigationBarBackgroundAlpha.h; sourceTree = "<group>"; };
676D498E20AE93420016ADBA /* NNNavigationBarTintColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NNNavigationBarTintColor.h; sourceTree = "<group>"; };
677CB32B22E1B52F001FA15C /* NNProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NNProxy.h; sourceTree = "<group>"; };
677CB32C22E1B52F001FA15C /* NNProxy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NNProxy.m; sourceTree = "<group>"; };
67E4569F20A0073A00E58475 /* NNNavigationBar.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NNNavigationBar.framework; sourceTree = BUILT_PRODUCTS_DIR; };
67E456A820A0073A00E58475 /* NNNavigationBarTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NNNavigationBarTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
67E456AD20A0073A00E58475 /* NNNavigationBarTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NNNavigationBarTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -230,6 +234,8 @@
676D496F20AE84090016ADBA /* UINavigationBar+NNCoreProperties.m */,
676D497620AE87BF0016ADBA /* UINavigationItem+NNCoreProperties.h */,
676D497720AE87BF0016ADBA /* UINavigationItem+NNCoreProperties.m */,
677CB32B22E1B52F001FA15C /* NNProxy.h */,
677CB32C22E1B52F001FA15C /* NNProxy.m */,
);
path = Core;
sourceTree = "<group>";
Expand Down Expand Up @@ -299,6 +305,7 @@
676D498C20AE92BB0016ADBA /* NNNavigationBarBackgroundAlpha.h in Headers */,
67E4570220A007C200E58475 /* UINavigationBar+NNBackgroundView.h in Headers */,
67E4570520A007C200E58475 /* UINavigationItem+NNBackgroundView.h in Headers */,
677CB32D22E1B52F001FA15C /* NNProxy.h in Headers */,
676D499020AE93420016ADBA /* NNNavigationBarTintColor.h in Headers */,
67E4572320A007C200E58475 /* UINavigationBar+NNTintColor.h in Headers */,
67E4572420A007C200E58475 /* UINavigationItem+NNTintColor.h in Headers */,
Expand Down Expand Up @@ -385,6 +392,7 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 67E4569520A0073900E58475;
productRefGroup = 67E456A020A0073A00E58475 /* Products */;
Expand Down Expand Up @@ -425,6 +433,7 @@
67E4571D20A007C200E58475 /* UINavigationBar+NNTintColor.m in Sources */,
676D497520AE85BC0016ADBA /* NNTransitionClass.m in Sources */,
676D497120AE84090016ADBA /* UINavigationBar+NNCoreProperties.m in Sources */,
677CB32E22E1B52F001FA15C /* NNProxy.m in Sources */,
67E4570A20A007C200E58475 /* UINavigationBar+NNMethodSwizzling.m in Sources */,
67E4571920A007C200E58475 /* UIImage+NNImageWithColor.m in Sources */,
67E456F520A007C200E58475 /* UINavigationBar+NNTransitionForBackgroundAlpha.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "NNFadeAnimationImageView.h"
#import "NSLayoutConstraint+NNVisualFormat.h"
#import "NNProxy.h"

@interface _NNAnimatedDisplayImageView : UIImageView @end
@implementation _NNAnimatedDisplayImageView @end
Expand Down Expand Up @@ -129,7 +130,7 @@ - (void)setNn_animating:(BOOL)nn_animating {
}

- (void)_nn_startLinkTick {
self._nn_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_nn_handleLinkTick)];
self._nn_displayLink = [CADisplayLink displayLinkWithTarget:[NNProxy proxyWithTarget:self] selector:@selector(_nn_handleLinkTick)];
[self._nn_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
}

Expand Down
17 changes: 17 additions & 0 deletions NNNavigationBar/NNNavigationBar/Core/NNProxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// NNProxy.h
// NNNavigationBar
//
// Created by GuHaijun on 2019/7/19.
// Copyright © 2019 GuHaijun. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NNProxy : NSProxy

@property (nonatomic, weak, readonly)id target;
+ (instancetype)proxyWithTarget:(id)target;
- (instancetype)initWithTarget:(id)target;

@end
37 changes: 37 additions & 0 deletions NNNavigationBar/NNNavigationBar/Core/NNProxy.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// NNProxy.m
// NNNavigationBar
//
// Created by GuHaijun on 2019/7/19.
// Copyright © 2019 GuHaijun. All rights reserved.
//

#import "NNProxy.h"

@implementation NNProxy

+ (instancetype)proxyWithTarget:(id)target{
return [[self alloc] initWithTarget:target];
}

- (instancetype)initWithTarget:(id)target{
_target = target;
return self;
}

- (BOOL)respondsToSelector:(SEL)aSelector{
return [self.target respondsToSelector:aSelector];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector{
return [self.target methodSignatureForSelector:aSelector];
}

- (void)forwardInvocation:(NSInvocation *)invocation{
SEL sel = [invocation selector];
if ([self.target respondsToSelector:sel]) {
[invocation invokeWithTarget:self.target];
}
}

@end
Loading

0 comments on commit 270ae15

Please sign in to comment.