SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.16k stars 223 forks source link

iOS 14, WidgetKit, Preview, ImageManager doesn't load image #137

Open iDevPro opened 3 years ago

iDevPro commented 3 years ago

Latest SDWebImage from pod

WebImage(url: imageUrl) in preview work like a charm, but

@ObservedObject private var imageManager: ImageManager

init(imageUrl: URL?) {
      imageManager = ImageManager(url: imageUrl)
}

var body: some View {
    Group {
       if let image = imageManager.image {...} else {...}
    }
    .onAppear { self.imageManager.load() }
    .onDisappear { self.imageManager.cancel() }
}

Doesn't work in preview, but work in simulator :))

dreampiggy commented 3 years ago

Low level...I don't think this is something we can do.

I doubt that WebImage can not show animation on WidgetKit. Because using WidgetKit, every Runloop/Timer, which drive the animation, will be stopped between iOS 14's Widget timeline update.

berchan commented 3 years ago

推测和swiftUI视图生命周期关联,可以试试在onDisappear不进行取消操作,同时关闭该插件的cancelOnDisappear

Jdb156158 commented 1 year ago

这个问题解决了吗?iOS 14, WidgetKit中怎么去显示动图啊,大佬们