alexiscreuzot / SwiftyGif

High performance GIF engine
MIT License
2.01k stars 211 forks source link

Remote Gif is running but will not display #114

Closed BaxiaMashia closed 4 years ago

BaxiaMashia commented 5 years ago

For the life of me I can't get the GIF to display. Is there something I'm missing here?

          `var outgoingMessageView: UIImageView!

        outgoingMessageView = UIImageView(frame:
            CGRect(x: llamaView.frame.maxX - 50,
                   y: llamaView.frame.minY + 75,
                   width: bubbleImageSize.width,
                   height: bubbleImageSize.height))
        outgoingMessageView.delegate = self

        if textIsValidURL == true {
            print("URL is valid")
            outgoingMessageView.image = bubbleImage
            let maskView = UIImageView(image: bubbleImage)
            maskView.frame = outgoingMessageView.bounds
            outgoingMessageView.mask = maskView
            outgoingMessageView.frame.origin.y = llamaView.frame.minY - 25
            let url = URL(string: text)
            outgoingMessageView.setGifFromURL(url, manager: .defaultManager, loopCount: -1, showLoader: true)
        } else {
            outgoingMessageView.image = bubbleImage
        }            
        // Set the animations
        label.animation = "zoomIn"
        //outgoingMessageView.animation = "zoomIn"

        // Add the Subviews
        view.addSubview(outgoingMessageView)
        print("outgoingMessageView added")`

The delegate lets me know it runs successfully via:

gifDidStart gifURLDidFinish

Checking outgoingMessageView.isAnimatingGif() tells me it's still running. Checking outgoingMessageView.isDisplayedInScreen(outgoingMessageView) tells me it's not being displayed

It "finishes" almost immediately, but it's the same in your example project, yet the gif still loops and displays in your project. I've changed loop counts, imageviews, not running via a mask as I intended and instead just a UIImageView, changed the GIF urls, all to no avail. Help!

Using the latest SwiftyGIF version

BaxiaMashia commented 5 years ago

Still looking for help if anyone has some suggestions! Thanks!

alexiscreuzot commented 5 years ago

Did you try with another GIF URL, like this one for instance : https://i.imgur.com/eZcQvpc.gif Also maybe remove the masking. I tried with this simplified code and it works :

        outgoingMessageView = UIImageView(frame:imageView.frame)
        outgoingMessageView.delegate = self

        let url = URL(string: "https://i.imgur.com/eZcQvpc.gif")!
        outgoingMessageView.setGifFromURL(url, manager: .defaultManager, loopCount: -1, showLoader: true)
        view.addSubview(outgoingMessageView)