SubviewAttachingTextView icon indicating copy to clipboard operation
SubviewAttachingTextView copied to clipboard

Attachment views disappeared after tableView scrolling

Open goodlord01 opened this issue 3 years ago • 1 comments

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?

goodlord01 avatar Oct 13 '21 09:10 goodlord01

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
}

salabaha avatar Jul 05 '22 22:07 salabaha