【问题标题】:Update image of NSTextAttachment once already rendered [duplicate]一旦已经渲染,更新 NSTextAttachment 的图像[重复]
【发布时间】:2016-01-18 19:58:41
【问题描述】:

我有一个 NSTextAttachment,我想显示加载图像,直到图像下载完成,然后我想更新图像。

除了我第二次调用textAttachment.image = image 时没有任何反应。

NSTextAttachment 已经被 UITextView 渲染后,我该如何更新它?

谢谢!

【问题讨论】:

    标签: uiimage uitextview nstextattachment


    【解决方案1】:

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

    这是一个 Swift 示例:

    // Update UI from main thread
    dispatch_async(dispatch_get_main_queue(), {
      textAttachment.image = image
    })

    【讨论】:

      猜你喜欢
      • 2017-05-24
      • 1970-01-01
      • 1970-01-01
      • 2020-01-22
      • 2014-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多