简体   繁体   English

iPad 模拟器上的 SKScene 问题未在 Xcode 11 beta 7 中填充屏幕

[英]Issues with SKScene on iPad simulator not filling screen in Xcode 11 beta 7

In Xcode 11 beta 7, I am having issues with my SKScene , my GameScene does not fill the entire screen of the iPad simulator.在 Xcode 11 beta 7 中,我的SKScene出现问题,我的 GameScene 没有填满 iPad 模拟器的整个屏幕。 This is true for all iPad simulators.这适用于所有 iPad 模拟器。 On my physical iPad the Game Scene is as intended, but I worry this may not be true of all iPad's.在我的物理 iPad 上,游戏场景符合预期,但我担心这可能不适用于所有 iPad。 On all iPhone simulators and on my iPhone, the Game Scene is also displayed as intended.在所有 iPhone 模拟器和我的 iPhone 上,游戏场景也按预期显示。

I have two SKScenes , one is the Main Menu screen which fills the entire screen, but my Game Scene does not, when I load the Game Scene it is square and the Main Menu screen is visible underneath, like so:我有两个SKScenes ,一个是填充整个屏幕的主菜单屏幕,但我的游戏场景没有,当我加载游戏场景时,它是方形的,主菜单屏幕在下面可见,如下所示:

.aspectFill

The following is the code for my GameViewController , which is practically identical to my MainMenuViewController except all instances of "Game" are "MainMenu":以下是我的GameViewController的代码,除了“Game”的所有实例都是“MainMenu”之外,它实际上与我的MainMenuViewController相同:

class GameViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Load 'GameScene.sks' as a GKScene. This provides gameplay related content
        // including entities and graphs.
        if let scene = GKScene(fileNamed: "GameScene") {

            // Get the SKScene from the loaded GKScene
            if let sceneNode = scene.rootNode as! GameScene? {

                // Copy gameplay related content over to the scene
                sceneNode.entities = scene.entities
                sceneNode.graphs = scene.graphs

                // Set the scale mode to scale to fit the window
                sceneNode.scaleMode = .aspectFill

                // Present the scene
                if let view = self.view as! SKView? {
                    view.presentScene(sceneNode)

                    view.ignoresSiblingOrder = true

                    view.showsFPS = true
                    view.showsNodeCount = true
                }
            }
        }
    }

    override var shouldAutorotate: Bool {
        return true
    }

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        if UIDevice.current.userInterfaceIdiom == .phone {
            return .allButUpsideDown
        } else {
            return .all
        }
    }

    override var prefersStatusBarHidden: Bool {
        return true
    }
}

I have tried changing the line sceneNode.scaleMode = .aspectFill to sceneNode.scaleMode = .aspectFit , but that produces the following:我曾尝试将行sceneNode.scaleMode = .aspectFillsceneNode.scaleMode = .aspectFit ,但这会产生以下结果:

.aspectFit

So, how do I make my Game Scene, the red area, fill the entire iPad's screen?那么,如何让我的游戏场景(红色区域)填满整个 iPad 的屏幕?

Typical that after setting a bounty I find the answer.通常在设置赏金后我找到了答案。

The issue was in my storyboard file, not my code:问题出在我的故事板文件中,而不是我的代码中:

Originally, I had this in the properties of my view after the segue:最初,我在 segue 之后在我的视图属性中有这个:

原来的

And changing it to this made the SKView fill the entire screen:并将其更改为这样会使 SKView 填满整个屏幕:

改变了

Clearly at some point Xcode changed so that 'Automatic' no longer filled the screen for whatever reason.很明显,在某些时候 Xcode 发生了变化,因此无论出于何种原因,“自动”都不再填满屏幕。

Edit: For more clarification, when you open the storyboard file, click/select the view controller that you want to adjust, under the Attributes Inspector, there is an option for Presentation where you can select the "Full Screen" attribute.编辑:更多说明,当您打开故事板文件时,单击/选择要调整的视图控制器,在属性检查器下,有一个演示选项,您可以在其中选择“全屏”属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM