0

If I print self.size i get (320,480) but it should be (480,320) because my app is in landscape this is how I go to my main view:

var playScene = Menu(size: self.size)
let skView = self.view! as SKView

skView.ignoresSiblingOrder = true
playScene.scaleMode = .ResizeFill
playScene.size = skView.bounds.size
skView.presentScene(playScene)

Edit: I've found that on an Iphone 5s the self.size is (568, 320) so the problem is only on iphone 4s or on IOS 7

Clément Bisaillon
  • 5,037
  • 8
  • 32
  • 53

2 Answers2

0

The sizes of views aren't updated until UIKit runs layout. That happens after viewDidLoad returns. So if that code is in viewDidLoad, you're checking too soon. Look at the size in viewDidLayoutSubviews or viewDidAppear:.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
0

I've had to use this function to get the right screen size for the device i am using:

func screenSize() -> CGSize {
    var screenSize: CGSize = UIScreen.mainScreen().bounds.size
    if ((NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) && UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication().statusBarOrientation)) {//If ios 7

        return CGSizeMake(screenSize.height, screenSize.width);
    }
    return screenSize;
}

And i replace my code to change the view to:

var playScene = Menu(size: self.size)
let skView = self.view! as SKView

skView.ignoresSiblingOrder = true
playScene.scaleMode = .ResizeFill
playScene.size = screenSize()
skView.presentScene(playScene)
Clément Bisaillon
  • 5,037
  • 8
  • 32
  • 53