Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Wonderful.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ s.source = { :git => 'https://github.com/dsxNiubility/Wonderful.git', :tag => s.
s.requires_arc = true
s.ios.deployment_target = '7.0'
s.source_files = 'Wonderful/*.{h,m}'
s.dependency 'YYText'

end
16 changes: 14 additions & 2 deletions Wonderful/SXHeadLine.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "SXHeadLine.h"
#import "SXColorGradientView.h"
#import <YYText/YYTextWeakProxy.h>

#define kSXHeadLineMargin 10

Expand All @@ -31,7 +32,7 @@ @interface SXHeadLine ()
@property (nonatomic,copy ) actionBlock tapAction;
@property (nonatomic,assign) SXMarqueeTapMode tapMode;


@property (nonatomic, strong) YYTextWeakProxy *weakProxy;
@end
@implementation SXHeadLine

Expand Down Expand Up @@ -74,6 +75,8 @@ - (void)removeCompoment{
}

- (void)dealloc{
[self.timer invalidate];
self.timer = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

Expand Down Expand Up @@ -113,7 +116,9 @@ - (void)start{
if (self.messageArray.count < 2) {
return;
}
NSTimer *timer = [NSTimer timerWithTimeInterval:_stayDuration target:self selector:@selector(scrollAnimate) userInfo:nil repeats:YES];
// 使用NSTimer在`repeats`设置为`yes`时NSTimer会持有target造成循环引用,
// 可参考https://stackoverflow.com/questions/16821736/weak-reference-to-nstimer-target-to-prevent-retain-cycle
NSTimer *timer = [NSTimer timerWithTimeInterval:_stayDuration target:self.weakProxy selector:@selector(scrollAnimate) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop]addTimer:timer forMode:NSRunLoopCommonModes];
self.timer = timer;
}
Expand Down Expand Up @@ -245,5 +250,12 @@ - (void)bgButtonPress
}
}

- (YYTextWeakProxy *)weakProxy {
if (!_weakProxy) {
_weakProxy = [YYTextWeakProxy proxyWithTarget:self];
}
return _weakProxy;
}

@end

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>