iAd Banner is messing up scene in SpriteKit - ios

I think I've looked through all the previous posts that are similar to this problem and couldn't find a solution so I hope someone can help me.
I've got a very simple game using SpriteKit. The game is in portrait mode only. When I view the game in the simulator, the ads appear perfect but they are on top of my content and have also shifted the top content off the screen so you can barely see the scores. I'm not sure if I need to do something in the ViewController or the scene itself that has the ads running, but I think the ViewController is the correct place.
I'm hoping someone else had this problem and figured it out. I saw some people say that using:
scene.scaleMode = SKSceneScaleModeAspectFill;
or
scene.scaleMode = SKSceneScaleModeAspectFit;
changed their views to work. I'm using "fill" but I tried "fit" and neither seemed to do anything. Ideally the top of the banner is the new bottom of my screen and I can get everything to fit in the new smaller size but I'm kinda of stuck at the moment. Thanks for any help you can provide!

I had the same issue and instead of using AspectFill or AspectFit
use this.
scene.scaleMode = .Fill
This option didn't cover up as much content as the others.

Related

Weird padding at top UINavigationController while animating to detail in iOS11

I'm posting here because I'm completely lost on this one.
I've searched all over the web, tried a lot of things myself, and searched weeks on this bug, but I can't find it.
So ever since iOS 11 (doesn't happen on iOS 10), everytime I press a button that activates the "show" segue in a UINavigationController the animation shows some weird padding at the top.
This padding disappears when the animation is finished.
I've changed the backgroundcolor of the superview to a red color, and the space you can see is indeed from the superview itself, so my guess is the whole UITableView is being moved down for some reason, although I'm not sure what exactly is the cause here.
(I'm using storyboard and AutoLayout constraints)
Another thing I noticed is that the spacing/padding you see is different on the iPhone X compared to the other devices (my guess is that it's the same height as the (non)safe area at the top? Again, not sure.
I don't think code is necessary to be provided here, as I wouldn't really know which part causes this behaviour (and there's a lot of code that I can't share for reasons..).
Any suggestions/help on how to fix this would be deeply appreciated!
Here are some examples:
iPhone X running iOS 11.1 (also happened on 11.0)
iPhone 8 gif
EDIT: I should add, some things I already tried:
tableView.contentInsetAdjustmentBehavior = .never
Setting headerviews to 0
tableView.setContentOffset(0, animated: false)
Playing with the translucency settings of the UINavigationBar
AutomaticallyAdjustContentInsets is set to false
So, as suggested by Spenser-Arn, I played around with the constraints and the Safe Areas, turns out, the safe areas where the cause of the issue.
Hope this helps other people as much as it helped me, and a big thankyou to Spenser-Arn!

UISplitViewController Share same Header

Im facing an issue that I don't know if it's possible to solve I need to develop something that looks like this for iPhone, Ipad
iPad:
iPhone:
How can I accomplish this?
On iPhone the only way to get the SplitView to look like an iPad's is if the device is flipped sideways. It won't preserve the solid header on the Navigation Controller. There are a few topics Here and
Here that might be able to help you a little more.
Theres some code indicated that might be what you are looking for to help you preserve the solid header, but as far as I know there's no way to do it on iPhone - at least in Portrait orientation. I'm thinking that this code might fix your problem, but I havent tested it yet...
Put the following in you Master View controller:
self.splitViewController!.delegate = self;
self.splitViewController!.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
self.extendedLayoutIncludesOpaqueBars = true

Inspect SpriteKit Scene at Runtime

I am generating my levels in SpriteKit via code (in Swift), and its not working out entirely how I'd like. Is there a way to inspect the scene of the simulator at run time. E.g. So I can view how things are being placed outside the visible screen.
Thanks!
Believe me, level editor via code rarely is a good idea. There are exceptions but if you need static levels then you should find another way to defined it.
How can you see your entire scene?
AFAIK you con't with Xcode 7, however you can change how the scene is resize in order to show the full scene inside the view. Depending by the size of your level you can judge whether this is solutions fits your case.
Just open GameViewController.swift and change this
scene.scaleMode = AspectFill
into this
scene.scaleMode = .AspectFit
Now your scene will be compressed to fit the size of the screen. Of course don't forget to restore the original value once you are done.

Spritekit scene editor size

I am trying to get into the sprite kit scene editor that recently came out, and having some difficulties. My main problem is that i can't seem to understand the size of it.
The current size is 1024 x 768. So i start adding nodes to it, and then run it as an iPhone app, and now it won't show my nodes. They simple get left out since it resizes it. My problem is, i thought it would handle this automatically (scale it to fit), but it doesn't.
so my question is, how do you handle this? I mean Apple has a lot of different screen sizes now, so how on earth are one supposed to match this? Surely you aren't supposed to create an entire scene for each screen size, there must be a better way? I just have no clue. I thought this code would take care of it (standard code when making a new spriteKit project) in the GameViewController that presents the scene:
// Create and configure the scene.
GameScene *scene = [GameScene unarchiveFromFile:#"GameScene"];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
But it doesn't. It displays it all if i'm running it on an iPad in landscape mode, but not if i switch to portrait or run in any iPhone orientation.
So how do you support multiple screen sizes with this new editor? And if anyone can point me to a resource where i can learn more about this editor i would be thrilled.
Thanks in advance,
Best Regards,
/JBJ

How can I make the motion smoother?

I'am programming my first game for Ipad. I have a little problem on an animation. In this game I have a ball bouncing around the screen. I move the ball in this way
CGRect frameRect = ball.frame;
frameRect.origin.x += ballMovement.x;
frameRect.origin.y += ballMovement.y;
ball.frame=frameRect;
The ball moves but the animation is sometimes not very smooth... The strange thing is that while I was testing my app on my ipad I discovered that if I close the app and reopen it from the multitasking bar the ball moves way way better! The animation is smoother and faster...
Can somebody explain why is happening this thing?
Thank you!! Daniel from Italy
If reopening the application makes it smooth, then most likely something has been cached the second time that was not cached the first time. There's nothing in the 4 lines of code you posted that could explain the lack of smoothness. Maybe posting more of the code would help.

Resources