且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

背景没有填满整个视图 SpriteKit

更新时间:2023-11-17 16:44:04

这听起来很愚蠢,但你有启动屏幕吗?我遇到了同样的问题,它只会在 Xcode 12 而不是 11 中发生,但我发现的主要区别是 Xcode 11 有一个启动屏幕.一旦我添加了启动屏幕故事板并将其添加到我的 plist 中,我的 SCNView 就会填满屏幕.我不确定为什么这会导致视图不遵循约束,但在将其添加到我的其他项目后,它解决了这个问题.

This is going to sound dumb, but do you have a launch Screen? I was having the same problem which would only happen in Xcode 12 and not 11, but the main difference I found was Xcode 11 has a launch screen. Once I added the launch screen storyboard and added it to my plist my SCNView would fill the screen. I am not sure why this would cause the view not to follow the constraints, but after adding it to my other projects it fixes the issue.

您不需要启动屏幕故事板,您只需在启动屏幕界面文件基本名称"下的 plist 中添加显示场景的主故事板.

You do not need to have a launch screen storyboard, you can just add your main storyboard that displays you scene in the plist under "Launch screen interface file base name".