From d82df3b5386358ddf82f8b591d8b378d5eddfc50 Mon Sep 17 00:00:00 2001 From: Lee <18611401994@163.com> Date: Tue, 7 Jul 2020 12:49:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DUITextView=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AttributedString.podspec | 2 +- AttributedString.xcodeproj/project.pbxproj | 16 ++++++++-------- .../Extension/UIKit/UITextViewExtension.swift | 11 ++--------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/AttributedString.podspec b/AttributedString.podspec index 03bbb40..29bc4bb 100644 --- a/AttributedString.podspec +++ b/AttributedString.podspec @@ -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" diff --git a/AttributedString.xcodeproj/project.pbxproj b/AttributedString.xcodeproj/project.pbxproj index 86b6988..7571b7a 100644 --- a/AttributedString.xcodeproj/project.pbxproj +++ b/AttributedString.xcodeproj/project.pbxproj @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/Sources/Extension/UIKit/UITextViewExtension.swift b/Sources/Extension/UIKit/UITextViewExtension.swift index ec4b1ac..9eb999c 100644 --- a/Sources/Extension/UIKit/UITextViewExtension.swift +++ b/Sources/Extension/UIKit/UITextViewExtension.swift @@ -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)? {