Closed CollinAlpert closed 3 years ago
Hey, what arguments do you pass to URLImage
, how do you construct URL?
I wrote this extension method:
extension URLImage where Empty == EmptyView,
Failure == Text,
InProgress: View {
init(url: URL, content: @escaping (_ image: Image) -> Content) {
self.init(url: url, options: URLImageOptions(), empty: {Text("An image should appear here shortly.")}, inProgress: {_ in if #available(iOS 14.0, *) {
return ProgressView() as! InProgress
} else {
// Fallback on earlier versions
return EmptyView() as! InProgress
}}, failure: {_,_ in Text("Error").foregroundColor(Color.red)}, content: content)
}
}
And then one possible call would be the following:
URLImage(url: URL(string: "https://nightspot.app/api/icons/ic_euro.png")!) { image in
HStack(alignment: .lastTextBaseline) {
image.resizable().frame(width: 20, height: 20).offset(y: 4)
Text(o.description).foregroundColor(Color.black)
Spacer()
}
}
I see, but this is a different URL. Is this URL also not loading?
Yes, different URL, but it also doesn't work. I've tried multiple PNG images.
Both URLs work on my machine, but I use iOS 14.0 simulator. I'm gonna install 14.1 and get back to this issue tomorrow. In meanwhile, if you want to investigate, there is Log.swift file where you can log_detail = log_all
.
Thanks, I'll check that out. Like I said, if I just build a small repro, it also works for me. I was just wondering if you were aware of some issues in any specific constellations.
Hey, I don't see any issues with 14.1. There's probably something around that causes the issue. I'm gonna mark the issue as "Cannot Reproduce" but keep open for some time. I appreciate help in finding a reproducible scenario.
I just tried adding the dependency via CocoaPods and it works fine (appears to be using version 2.1.4)! I was previously using the Swift package manager and version 2.0.0 which didn't work for me. I doubt it was the switch to CocoaPods that fixed it so it must be something in the code since then.
Cool. BTW you can install 2.1.4 via SPM
Summary and/or background In some instances, when displaying a PNG image, the download doesn't start. I have verified this by using the
empty
argument. Unfortunately, I cannot create a reproduction view, because every time I do, it works. But in my app, when trying to display a PNG image, the download does not start. I know not being able to provide a reproduction is unfortunate, but is there anything you can think of that could cause this?OS and what device you are using
Version of URLImage library The version of the library where the bug happens.
What you expected would happen The PNG image is displayed in my app.
What actually happens The image is not displayed, instead the result of the
empty
argument is.Sample code Sorry about this, I can't seem to isolate the problem.
Test data https://nightspot.app/api/München/P1/logo.png
Additional information: