SubviewAttachingTextView
SubviewAttachingTextView copied to clipboard
Attachment views disappeared after tableView scrolling
I've put a SubviewAttachingTextView textView inside a tableView, and it contains several images and subviews, when I scroll the tableView, the images and subviews disappear, leaving blank spaces, I've tried to reset attributedString in willDisplayCell, but it doesn't solve the problem, can you give me a hint on how to fix that? Or is it just a tableView caching issue?
I have experienced SubviewAttachingTextView rendering issues when SubviewAttachingTextView is inside reusable table view cell.
I have resolved this issue by adding invalidate function to SubviewAttachingTextView and call it form UITableViewCell.prepareForReuse function.
func invalidate() {
attachmentBehavior = SubviewAttachingTextViewBehavior()
attributedText = nil
bindAttachmentBehavior()
}
func bindAttachmentBehavior() {
attachmentBehavior.textView = self
layoutManager.delegate = self.attachmentBehavior
textStorage.delegate = self.attachmentBehavior
}