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
|
1 answer
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) |
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 soskView = 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