Kingfisher: KFImage does not render when applying modifier

Created on 18 Jun 2020  Â·  6Comments  Â·  Source: onevcat/Kingfisher

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

Issue Description

When using a modifier that transforms a view which contains a KFImage into a Button. The download process seems to fail and the image does not show even if the callback for the KFImage returns successful.

What

I have view which contains the KFImage such as:

var body: some View {
    VStack {
        KFImage(url)
    }
}

And I apply a modifier to this view which will result in the content being inside the button.

self // <--- View which contains KFimage
    .modifier(
          Button(
              action: { //some action code.  },
              label: { content  // <--- View which contains KFimage }
         )
    )

Sorry for the short code description, I tried to simplify as much as I could to pass down the issue. First time creating an issue related to KF.

Other Comment

[Add anything else here]

Most helpful comment

I realized my issue is actually that SwiftUI natively changes the image type for Buttons and Navigation links. I had to set .renderingMode(.original) on the Image, and that fixed it for me!

All 6 comments

@hcjordao

Thanks for reporting thi.

But I am still confusing which view is containing KFImage. Is it self or content or both?

Can you paste a working example in which we can reproduce this issue? So we can ensure we are in the same context and try to dig into it.

No problem 🚀

They are both the same view. Self is used because it will act like a function.

The function would look something like this:

viewWhichContainsKingfisherImage.modifierToButton()

This will result in the view being embeded inside the Button in SwiftUI

Did you figure out how to solve this? I've noticed when I have a KFImage in something like a Button, it doesn't download the image and update the view

I realized my issue is actually that SwiftUI natively changes the image type for Buttons and Navigation links. I had to set .renderingMode(.original) on the Image, and that fixed it for me!

That also solved for me thanks @ZMcGuckin 🚀

Glad I could help! It was bugging me as well and when I swapped King Fisher for another Swift Package I saw the solution there

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Minitour picture Minitour  Â·  4Comments

joebenton picture joebenton  Â·  4Comments

freak4pc picture freak4pc  Â·  3Comments

vCrespoP picture vCrespoP  Â·  3Comments

SURYAKANTSHARMA picture SURYAKANTSHARMA  Â·  4Comments