The uiimageview animation stops when the user touches the screen

I have a UImageview with an animated image. I add uiimageview to the code and part of it. CollectionViewCell When the user touches the cell, the animation stops, why is this happening?

the code:

 var images: [UIImage] = []
for i in 0...10 {
   images.append(UIImage(named: "image\(i)"))
}

        let i = UIImageView(frame: CGRect(x: xPos, y: yPos, width: 200, height: 200))
        i.animationImages = images
        i.animationDuration = 0.5
        i.startAnimating()
        i.contentMode = UIViewContentMode.Center
        i.userInteractionEnabled = false

        self.addSubview(i) 
+4
source share
2 answers

In the cell class of a custom collection view, write the following methods to resolve the problem

func setSelected(selected:Bool) {

}

func setHighlighted(higlighted:Bool) {

}
+2
source

Swift 4.0 Version:

override open var isSelected: Bool
{
    set {

    }

    get {
        return super.isSelected
    }
}

override open var isHighlighted: Bool
{
    set {

    }

    get {
        return super.isHighlighted
    }
}
+1
source

Source: https://habr.com/ru/post/1570882/


All Articles