Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b2e7aa2

Browse files
committed
点击优化
1 parent 137b5ed commit b2e7aa2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎MYCoreText_Example/MYCoreTextLabel/MYCoreTextLabel.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,12 @@ - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
320320
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
321321
{
322322
[self dismissAnimation];
323-
if ([self.delegate respondsToSelector:@selector(coreTextLabelLinkTouch:link:type:)]) {
324-
[self.delegate coreTextLabelLinkTouch:self link:self.currentTouchLink.linkText type:self.currentTouchLink.linkType];
325-
}
323+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
324+
if ([self.delegate respondsToSelector:@selector(coreTextLabelLinkTouch:link:type:)]) {
325+
[self.delegate coreTextLabelLinkTouch:self link:self.currentTouchLink.linkText type:self.currentTouchLink.linkType];
326+
}
327+
self.currentTouchLink = nil;
328+
});
326329
}
327330

328331
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
@@ -338,12 +341,14 @@ - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
338341
}
339342
if (!isContained) {
340343
[self dismissAnimation];
344+
self.currentTouchLink = nil;
341345
}
342346
}
343347

344348
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
345349
{
346350
[self dismissAnimation];
351+
self.currentTouchLink = nil;
347352
}
348353

349354

@@ -393,7 +398,6 @@ - (void)addSelectedAnimation:(MYLinkModel *)linkModel
393398
#pragma mark - 点击动画
394399
- (void)dismissAnimation
395400
{
396-
self.currentTouchLink = nil;
397401
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
398402

399403
for (UIView *coverView in self.subviews) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /