一旦渲染,就更新NSTextAttachment的图像

Jas*_*man 9 uitextview uiimage nstextattachment

我有一个NSTextAttachment,我想显示一个加载图像,直到图像下载,然后一旦它我想要更新图像.

我有所有的逻辑,除非我textAttachment.image = image第二次打电话没有任何反应.

如何更新NSTextAttachment已经由UITextView?呈现的?

谢谢!

rjo*_*don 0

您必须始终从主线程而不是从套接字线程更新用户界面。

这是一个 Swift 示例:

// Update UI from main thread
dispatch_async(dispatch_get_main_queue(), {
  textAttachment.image = image
})
Run Code Online (Sandbox Code Playgroud)