Skip to content

Commit

Permalink
修复UITextView的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiang1994 committed Jul 7, 2020
1 parent 9d2f8e0 commit d82df3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion AttributedString.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "AttributedString"
s.version = "1.5.0"
s.version = "1.5.1"
s.summary = "基于Swift字符串插值快速构建你想要的富文本, 支持点击按住等事件获取, 支持多种类型过滤"

s.homepage = "https://github.com/lixiang1994/AttributedString"
Expand Down
16 changes: 8 additions & 8 deletions AttributedString.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.watchos;
PRODUCT_NAME = AttributedString;
SDKROOT = watchos;
Expand Down Expand Up @@ -852,7 +852,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.watchos;
PRODUCT_NAME = AttributedString;
SDKROOT = watchos;
Expand All @@ -879,7 +879,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.tvos;
PRODUCT_NAME = AttributedString;
SDKROOT = appletvos;
Expand All @@ -906,7 +906,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.tvos;
PRODUCT_NAME = AttributedString;
SDKROOT = appletvos;
Expand Down Expand Up @@ -982,7 +982,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.macos;
PRODUCT_NAME = AttributedString;
SDKROOT = macosx;
Expand All @@ -1009,7 +1009,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.macos;
PRODUCT_NAME = AttributedString;
SDKROOT = macosx;
Expand Down Expand Up @@ -1156,7 +1156,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.ios;
PRODUCT_NAME = AttributedString;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -1184,7 +1184,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.ios;
PRODUCT_NAME = AttributedString;
SKIP_INSTALL = YES;
Expand Down
11 changes: 2 additions & 9 deletions Sources/Extension/UIKit/UITextViewExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,10 @@ fileprivate extension UITextView {
@objc
func attributedAction(_ sender: UIGestureRecognizer) {
guard isActionEnabled else { return }
guard let (string, range, action) = touched else { return }
guard let action = touched?.2 else { return }
guard action.trigger.matching(sender) else { return }

// 点击 回调
let substring = string.value.attributedSubstring(from: range)
if let attachment = substring.attribute(.attachment, at: 0, effectiveRange: nil) as? NSTextAttachment {
action.callback(.init(range: range, content: .attachment(attachment)))

} else {
action.callback(.init(range: range, content: .string(substring)))
}
action.handle?()
}

func matching(_ point: CGPoint) -> (NSRange, Action)? {
Expand Down

0 comments on commit d82df3b

Please sign in to comment.