Splash screen look different on device vs storyboard - xcode

I'm trying to make a splash screen on ios, but weird is, it fit perfectly when using storyboard but not fit when using simulator or real device
It show perfect on storyboard
But small in real or simulator
Please help, i don't know what going on

Set Top, Bottom, Leading, and Trailing constraints to 0. Don't Give Height and Width to it, just constraints are enough.

Related

SKSceneScaleModeResizeFill on ios8 scales improperly

I have written a game in SpriteKit using objective C and it works perfectly on ios9 but it looks hideous on ios8. I would really like to know how to fix this problem, either by “correcting” my mistake, or if I have no mistake then by finding a workaround for the bug in ios8.
I think I have really done all I can to make the problem as clear as possible, including making loads of screenshots to illustrate the problem and also making a new Xcode project that is as simple as possible while still showing the problem.
If you want to try the Xcode project, here is a link for it….
xcode project
If you want to see the screenshots of the problem, then here is a link for the screenshots.
Screenshots
Now I will try to explain the code I wrote and the problem illustrated in the screenshots.
PLEASE REMEMBER: My code works perfectly on iOS9.3. So my code is obviously not complete gargage. But admittedly, I am not an expert on handling screen rotation, so probably my code could be better.
I should probably mention that both scenes have scale mode set to SKSceneScaleModeResizeFill. I chose this mode because I had tremendous difficulty doing proper layouts for all possible screen sizes (including iPhone) when working with SKSceneScaleModeAspectFill. I do I hope I can solve this problem while sticking with SKSceneScaleModeResizeFill.
Anyway, my app is a SpriteKit game with two scenes. The main scene is the GameScene, where you play the game. And this scene has a pointer to the SettingsScene, where you can change the settings of the scene. (e.g. change the level of difficulty).
Anytime the user rotates the screen, GameViewController detects this change in viewWillTransitionToSize and tells the GameScene object about the new screen width and screen height. Game Scene then adjusts the positions of its sprites in consideration of the new screen orientation and then tells its SettingsScene object about the new screen width and height to that the Settings scene is properly laid out as well.
Please note that with this design, all sprites on BOTH scenes get repositioned any time the user rotates the screen REGARDLESS of which scene is actually active at that time..
As I said before, all works as expected on ios9.3. But on ios8, the result is attrocious. The screenshots illustrate one example of typical experience on ios8. If the user rotates the screen while using the game and then goes to the settings screen, he will see something awful. And will often be trapped in this terrible experience because the button for going back to the main game might not even be fitting on the screen anymore.
At first, it might seem like I am failing to reposition sprites for landscape mode in the settings scene. But this explanation is wrong. The text on the screen shows that the last layout was performed with the landscape orientation in mind.
So what is going wrong here?
Any suggestions would be highly highly highly highly appreciated.
Thanks!
-j
p.s. In case you don't want to look directly at the linked project file, here are some details about the example code. GameViewController implements viewTransitionToSize to handle any screen rotation. It directly tells the new screen dimensions to GameScene, which then tells SettingsScene. Both scenes rearrange their sprites in consideration of the new screen dimensions. And all goes well on ios9. On ios8, however, the inactive scene ends up looking hideaous when it is presented even though it clearly did reposition its sprites according to the new dimensions.
the problem is easily resolved by these lines....
gameScene.size = newScreenSize;
settingsScene.size = newScreenSize;
anytime the orientation changes.
This code is not required for ios9. The scene knows what size the screen is without assistance. But for ios8, it seems to be needed to add this code.

Change Background Color of Full Screen Application- Xcode

Good Afternoon helpful people!
I'm building a mac app that displays images. The app will be in fullscreen mode 100% of the time it is running.
My issue is that the images I am displaying do not fill the entire screen, therefore, showing a grayish background. Is there anyway to change this background color to Black? Or maybe it's the NSImageView that needs the background color changed?
I do not see anywhere in my Xcode Attributes Inspector to change color.
Thanks!
The solution to this is, in my case, to add an NSBox in storyboard and set its constraints so that it ALWAYS fills the view. Once you have done this, go to the Atrributes Inspector and change its Fill Color to your desired color.
The important part here is the constraints. Set Top, Bottom, Left, and Right space to 0. Hope that makes sense, i'm new to constraints.

How to do this simple thing with XCode's new Auto Layout feature?

Im trying to do something that seems like it should be a no-brainer. But alas, im too dumb to figure this one out. So i need help.
I have an iphone simulator (with a vertical orientation).
The main view has a subview (a blue UIView) that should be displayed in the bottom 25% of the screen. The final rendered screen would basically look like a white screen with the bottom section being blue.
I want the edges of the subview to hug the screen edge. But thats not the part I'm struggling with. The tricky thing is configuring the height of this subview (and the layout of its contents, if any) when I suddenly rotate the orientation of the simulator. If i do this, then everything looks odd.
I would also like to note that what I see in the Interface Builder (with Auto Layout enabled) looks nothing like the app when it loads in the simulator.
PS - for now i will keep playing around with this. maybe i will eventually reach a eureka moment.
* Updated with screen shots *
This is what my layout looks like in Interface Builder:
And this is what it ends up looking like in the simulator:
* Update 2 *
Ok. After updating my post with the screenshots, it dawned on me that the simulator doesn't look like the 4" screen version (even though it does on my computer screen). After running the 4" simulator i can see the the layout just like the IB layout. But this makes me wonder why auto-layout wasn't "smart" enough to adjust for the smaller 3.5" screen.
It looks to me like you have a fixed height constraint from the top edge of the blue view to the superview that is pushing content down - conversely you may have a fixed height view above it that is smooshing things. Try pinning the top edge of the blue view to the superview and lowering the priority or changing it from an equality to a less than equal to constraint.
In IB in XCode you can change the canvas size for iPhone layouts, look for the single button on the right hand side that looks like a rectangle with arrows above and below, or inside it. In the screenshot below it is the leftmost button.
You could simply turn off Auto Layout. Springs and struts can readily make your subview 25% of the superview's height.
Or, you can certainly stick with it, but you'll need to adjust the constraints in code. There's no way to establish such a constraint in the current version of Xcode. Set constraints in IB to pin the box to the bottom of the window and fix the height, setting an outlet for the height constraint. Then in -viewDidLoad, remove the height constraint and add a new constraint to the superview which expresses the height relationship you want.
This isn't to discourage you from learning Auto Layout, but to point out that it's a bit complicated, and that the constraint tools in IB are unintuitive and relatively weak. The WWDC video Introduction to Auto Layout is a good starting point.

grow or shrink UIImageView frame to fit the entire iPhone screen via AutoLayout?

So I'm still getting accustomed to the world of Auto Layout in iOS 6 and it's been a fun (or in plain English -- tough) migration coming over from strings & struts.
I have a UIImageView that's the background for a game I'm working on. Here's what a regular 3.5" Retina Display looks like in Interface Builder:
but if I change the "Size" pop-up in the Simulated Metrics field for the content view to "Retina 4 Full Screen", here's what I see:
And you can see the ugly black bar appearing along the bottom edge of the simulated iPhone 5 screen. This same ugly black bar makes it over to the compiled app running in the iPhone 5 simulator.
Are there any attributes or constraints I can apply via Interface Builder to get the UIImageView's frame to size correctly for the appropriate iPhone device screen size?
Or do I have to enter in constraints via code? (ugh)
I've watched the three WWDC videos and if the engineers covered the topic of sizing a view to fit a parent, they must have glossed over it really fast because I've haven't yet found or heard a decent method to get both UIImageView and NSImageView to size correctly to their parent views under both the iOS and MacOS side.
From what you're showing here, I think that what you want to do is drag the image to meet the bottom of the superview so that it takes up all of the space you want. On the bottom right in the IB view you will see a small, grey pill-shaped set of 3 buttons. Click the center one (once you have your imageView selected). It's the one that looks a little like this: |--|. It will bring up a list of constraints. Once you have done that, select "Bottom Space to Superview". You should then be able to switch between phones and have the image resize automatically.

set ios screen resolution in xcode4 storyboard

Am working on an ipod/iphone application that primarily captures a photo. Am designing the flow in xcode4 IB storyboard.
However, as you can see from the image it is taking the default resolution as 320x480 which causing the preview on ipod retina display to show up in a corner than full screen. How can I make the IB get device resolution and adjust the ratio accordingly?
I tried looking at project settings, build settings, info.plist however couldn't find an answer yet.
Thx
Those dimensions are in points, not pixels. They are correct. On retina displays, 320 points are equal to 640 pixels. If your application is only showing up in a quarter of the screen, it's likely the problem is in your code, not in how you have set things up in Interface Builder.

Resources