0

So I started a new project for Apple Watch and the progress is doing great, but one issue that I couldn't fix was the Memory Leak one. I need to put around 60 images on a ScrollAmound with digital crown rotation, but when it gets to the 20th the app just crashes. It looks like is because the memory is accumulating each time I change the picture. Could someone help me? This is the part of the code with the problem:

ZStack{
    Image("\(Images(rawValue: Int(scrollAmount))!)")
    
        .resizable()
        .aspectRatio(contentMode: .fit)
        .scaledToFit()
        .frame(height: 161.25)
        .cornerRadius(8)
        .opacity(isAnimating ? 0 : 1)
        .opacity (open ? 1 : 0)
        .rotationEffect(.degrees(scrollAmount * -45))
        .animation(.easeInOut(duration: 0.4).delay(0.2), value: isAnimating)
        .animation(.easeInOut(duration: 0.2), value: open)
}
.offset(y: 0)
.focusable(true)
.digitalCrownRotation($scrollAmount,
                      from: 0,
                      through: 62,
                      by: 1,
                      sensitivity: .low,
                      isContinuous: true,
                      isHapticFeedbackEnabled: true
)
.onChange(of: scrollAmount, perform: { value in
    //self.up = (value > prevScrollAmount)
    //self.prevScrollAmount = value

    if (scrollAmount.remainder(dividingBy: scrollAmount.truncate(places: 1)) == 0.00)
    {
        player3.play()

    }
})

I'm trying basically clean the past images so the memory doesn't keep accumulating each time that I change it.

burnsi
  • 6,194
  • 13
  • 17
  • 27
Kblo
  • 1

0 Answers0