move logic up

This commit is contained in:
Kevin G Christiano 2020-10-01 09:03:48 -04:00
parent 84a300eba7
commit 592e0a9591

View File

@ -251,6 +251,23 @@ public typealias ActionBlock = () -> ()
attributedText = nil
originalAttributedString = nil
text = labelModel.text
/*
* This is to address a reuse issue with iOS 13 and up.
* Even if you set text & attributedText to nil, the moment you set text with a value,
* attributedText will hold a dirty value from a previously reused cell even if reset() is
* appropriately called.
* Only other reference found of issue: https://www.thetopsites.net/article/58142205.shtml
*/
if #available(iOS 13, *) {
// Case where no attributes are set in the model but attributedText has a value.
if attributedText != nil, let text = text {
let attributedString = NSMutableAttributedString(string: text)
attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count))
attributedText = attributedString
}
}
hero = labelModel.hero
Label.setLabel(self, withHTML: labelModel.html)
isAccessibilityElement = hasText
@ -366,22 +383,6 @@ public typealias ActionBlock = () -> ()
attributedText = attributedString
originalAttributedString = attributedText
}
/*
* This is to address a reuse issue with iOS 13 and up.
* Even if you set text & attributedText to nil, the moment you set text with a value,
* attributedText will hold a dirty value from a previously reused cell even if reset() is
* appropriately called.
* Only other reference found of issue: https://www.thetopsites.net/article/58142205.shtml
*/
if #available(iOS 13, *) {
// Case where no attributes are set in the model but attributedText has a value.
if labelModel.attributes == nil && attributedText != nil, let text = text {
let attributedString = NSMutableAttributedString(string: text)
attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count))
attributedText = attributedString
}
}
}
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {