Skip to content

Commit a0fe84d

Browse files
committed
only set isSelectable, isEditable and isUserInteractionEnabled if we used makeInteract
1 parent bd0164a commit a0fe84d

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

AttributedTextView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'AttributedTextView'
3-
s.version = '1.0.0'
3+
s.version = '1.1.0'
44
s.license = { :type => "MIT", :file => "LICENSE" }
55
s.summary = 'Easiest way to create an attributed UILabel or UITextView (with support for multiple links and HTML)'
66
s.homepage = 'https://github.com/evermeer/AttributedTextView'

Sources/AttributedTextView.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ import UIKit
7777
_attributer = newValue
7878
self.attributedText = _attributer?.attributedText
7979

80-
self.isUserInteractionEnabled = true
81-
self.isSelectable = true
82-
self.isEditable = false
80+
if _attributer?.hasCallbacks() ?? false {
81+
// Without these makeInteract does not work
82+
self.isUserInteractionEnabled = true
83+
self.isSelectable = true
84+
self.isEditable = false
85+
}
8386
if let color = _attributer?.linkColor {
8487
self.linkTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: color]
8588
}

Sources/Attributer.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ open class Attributer {
2828
*/
2929
fileprivate var urlCallbacks: [String : ((_ link: String) -> ())] = [:]
3030

31+
/**
32+
Do we have interactions
33+
*/
34+
public func hasCallbacks() -> Bool {
35+
return urlCallbacks.count > 0
36+
}
37+
3138
/**
3239
The current active ranges that will be influenced by all functions.
3340
*/

0 commit comments

Comments
 (0)