0

I recently converted my project to be a be a universal app. Everything is positioned correctly on the iPhones and some of the iPad versions (it has the black bars on top and bottom, but that's not the issue here). On the iPad 2, the HUD node is shifted up by 125 points. I can't figure out why this is happening on the iPad 2, but not the iPad Air 2. Has anyone else had issues like this?

I've been trying to fix the issue by checking for the exact model of the device in code, but am running into some issues doing so. I've tried using UIDevice.current.model (and other variants), but that just returns either "iPhone" or "iPad", and doesn't give any specifics. I've found some other post explaining how to do this another way, but haven't gotten it to work yet. Does anyone have another way to find the specific model of the device so I can adjust the node for that device? I'm using swift 3.0 and it seems the syntax has changed quite a bit from version to version as well.

Here's the link to what I've been trying to do (without luck so far): iOS: How to determine the current iPhone/device model in Swift?

Community
  • 1
  • 1
claassenApps
  • 1,057
  • 5
  • 14

1 Answers1

0

Instead of worrying about iPhone/iPad, worry about aspect ratio. Do width/height on your scene to get the aspect ratio. If you are having trouble with iPad 2 and not iPad air 2, then I do not think your app is universal. If you could provide some source on how you create your scene I could tell you where you are going wrong.

Knight0fDragon
  • 15,949
  • 2
  • 20
  • 41
  • In the project settings, it says it is Universal. I create a level in the scene editor (.sks file) and create an instance of that level like this: `Level1(fileNamed: "Level1")` and in the viewDidLoad, I set the size of the scene like `self.scene?.size = CGSize(width: 1334, height: 750)` and set the scaleMode like `self.scene?.scaleMode = .aspectFit`. I create the base of the HUD as an SKSpriteNode with no texture, clear color and size of 1334, 750, set its anchorPoint and position, just like any other node and add it to the cameraNode. Don't the two devices have the same aspect ratio? – claassenApps Dec 22 '16 at 00:17
  • you should be specifying the scene size in your Level1.sks file, you should not be manually creating it – Knight0fDragon Dec 22 '16 at 00:19
  • yes they do, something else is going on though that is throwing you off, perhaps it is not correctly handling retina gfx, iPad 2 uses `(@1x` gfx, iPad Air 2 uses `@2x` gfx – Knight0fDragon Dec 22 '16 at 00:21
  • I do that as well - set the height and width in the .sks file, but if I don't have the scene size set in code, it zooms in on the scene. – claassenApps Dec 22 '16 at 00:21
  • you should not be setting it inside code, if you are zooming in, then you have a problem – Knight0fDragon Dec 22 '16 at 00:22
  • The objects within the scene are all positioned correctly, it's just the HUD node that is shifted up. I can't find any reason why its position would be correct on one iPad (and iPhones) but not the other iPad. It might have something to do with the `@1x` and `@2x`, but the other nodes/images within the scene appear fine and in the right position. – claassenApps Dec 22 '16 at 00:24
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/131201/discussion-between-knight0fdragon-and-claassenapps). – Knight0fDragon Dec 22 '16 at 00:25