1

I am trying to add a SKScene with a simple animation to a UICollectionCell.

I've got my SKView setup in the .xib file of the collection view cell.

If I run it and scroll, it works as expected. But if I change to a different view controller (in a tab bar controller) that also uses those types of cells and start scrolling, it will get stuck.

Here's how I am adding the SKScene:

@interface MAPostCollectionViewCell ()

@property (strong, nonatomic) IBOutlet SKView *viewAnimation;
@property (strong, nonatomic) MAHeartAnimation *heartScene;

@end

@implementation MAPostCollectionViewCell

-(void)layoutSubviews{

    [super layoutSubviews];

    self.heartScene = [MAHeartAnimation sceneWithSize:self.viewAnimation.bounds.size];
    self.heartScene.scaleMode = SKSceneScaleModeAspectFill;

    [self.viewAnimation presentScene:self.heartScene]; 

}

@end

And I only trigger the animation if the user taps a button.

But for the scope of this question, the animation doesn't really matter, as I am not touching that button, just scrolling the UICollectionView.

jonypz
  • 1,515
  • 1
  • 20
  • 35

1 Answers1

0

It turns out you should not use SpriteKit and UIKit this way. Even though they are modular frameworks, they are not performant when using together this way. I ended up using UIKit for the animations that I wanted, by using CALayers.

jonypz
  • 1,515
  • 1
  • 20
  • 35