Wednesday, March 30, 2016

Update image of NSTextAttachment once already rendered

Leave a Comment

I have an NSTextAttachment which I want to show a loading image until the image has downloaded and then once it has I want to update the image.

I have all of the logic in place, except when I call textAttachment.image = image the second time nothing happens.

How can I update the NSTextAttachment once it has already been rendered by the UITextView?

Thanks!

1 Answers

Answers 1

You must always update the user interface from the main thread, not from the socket thread.

Here is a Swift example:

// Update UI from main thread dispatch_async(dispatch_get_main_queue(), {   textAttachment.image = image })
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment