Yalantis / Koloda

KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS.
https://yalantis.com
MIT License
5.37k stars 805 forks source link

Crash on iOS 10.3.1 #419

Open mojtaba-almoussawi opened 5 years ago

mojtaba-almoussawi commented 5 years ago

Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [nan nan; nan nan]'

Crash is happening when loading Koloda view, on devices running iOS 10.3.2

 private func layoutCard(_ card: DraggableCardView, at index: Int) {
      if index == 0 {
            card.layer.transform = CATransform3DIdentity
            card.frame = frameForTopCard()
        } else {
            let cardParameters = backgroundCardParametersForFrame(frameForCard(at: index))
            let scale = cardParameters.scale
            card.layer.transform = CATransform3DScale(CATransform3DIdentity, scale.width, scale.height, 1.0)
            card.frame = cardParameters.frame
        }
    }

The reason of the crash is trying to get the scale width and height, where they are NaN For now i have added this condition before card layer transformation to check if height and width isNaN

  if scale.height.isNaN || scale.width.isNaN {
       return
   }
matthewjsloane commented 5 years ago

+1, having the same issue on the iPhone 5 simulator running on 10.3

benben2019 commented 5 years ago

i got the same issue on the iPhone 6s simulator , iOS 10.3.1