enter image description here Hello, I do scrolling for scenes, everything works, only the dimensions have changed, In GameSceneCollectionViewController.swift, the size is set as follows: let skView = cell.contentView.subviews.first as! SKView let skView = cell.contentView.subviews.first as! SKView and I used to have let skView = self.view as! SKView let skView = self.view as! SKView is the same as it is now impossible to write, gives an error, how to be? https://yadi.sk/d/DajYTg6AvLsxH

  • nothing is clear. why did you even change it if it worked before? - Max Mikheyenko
  • Previously, I just had a View, and now I did CollectionViewController - Leci
  • But you can somehow explain in more detail, such as the application started, this and that is on the screen, but it is necessary that this and this be. Like this - Max Mikheyenko
  • On the screen before, the size of the objects was written as follows: Block.size = CGSize(width: self.view!.bounds.size.width, height: self.view!.bounds.size.height) and in the view file, I do not know how correctly it is called (appears when creating a spritekit) the size of the scene was set as follows: let skView = self.view as! SKView let scene = Scene1(size: skView.bounds.size) skView.presentScene(scene) let skView = self.view as! SKView let scene = Scene1(size: skView.bounds.size) skView.presentScene(scene) Now I have the size of the scene specified in this file with the view so skView = cell.contentView.subviews.first as! SKView let scene = Scene1(size: skView.bounds.size) skView = cell.contentView.subviews.first as! SKView let scene = Scene1(size: skView.bounds.size) - Leci
  • With this writing in the scene, I have all the objects flattened - Leci

1 answer 1

If you need to change the cell size in the CollectionViewController, then use the delegate:

UICollectionViewDelegateFlowLayout

and this function:

  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: width, height: height) } 

if you need to change the size of the CollectionViewController itself, here:

 collectionView?.frame = CGRect(x: 0, y: 0, width: width, height: height)