iPhone game display is off the screen by 10 pixels or so on the device - iphone

I recently deployed my first iPhone app, a simple game, to my testing iPhone for the first time. Everything looks and runs fine on the simulator in Xcode, but on the iPhone the whole image is shifted up about 10 pixels or so. So the gameplay goes slightly offscreen on top and has a slim white/grey bar at the bottom. Has anyone encountered this before? I do have the status bar display turned off, I'm wondering if the device handles that flag differently than the simulator. I also have the rotation hardcoded to be in portraitRight mode at all times, and I have an extra line in the code to make the simulator do that automatically that's apparently not necessary on the device.
Everything is very simple, so I'm not sure where this glitch is coming from or even where to look.

Did you use Interface Builder to create your UI? If you did, then go and check each and every XIB file(s) objects' Size & Position as well as Autosizing in Size Inspector (command-3).
It's very important to check both: your coordinates might have gone wrong after some change you did and autoscaling works in weird ways unless you attach to correct edges. Apple documentation should help http://developer.apple.com/iphone/library/documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html

Related

Auto Layout not working properly

I'm using Xcode 9.2. I'm normally debugging my app on my iPhone X but lately I tried to check if my animations scale properly on both simulated iPhone SE and a physical iPhone 6S. To my surprise many constraints were pretty messed up as though they were still scaled in relation to iPhone X's dimensions. When I switched the "View as:" option in Storyboard to respectively iPhone 8 and SE, everything layed out properly. But only when this option matched the device I was running the app on. Strange, I thought this is just for previewing and shouldn't have any impact on the actual app. Has anyone encountered it ?
I think I know the culprit...I was calling a method that was animating the layout too early - in viewDidLoad. I guess the views weren't properly placed and sized yet, that's why iOS used a default size which happens to be the last viewed device size in Storyboard.

Weird iPhone 4 simulator behavior - UITextViews stacked on top of each other

I just finished up my storyboard based iPhone app (I'm developing on an iPhone 5). Just before submitting it to the Appstore, I thought of making sure everything looks fine on an iPhone 4. So I launch my app in the simulator with iPhone 4.
And what I see baffles me. Basically every single view object, particularly textview, are stacked on top of each other. Basically everything scrollable's messed up. In some textviews even, the initial scroll position has been set to say 100px, which means that the textview's showing the middle of the content in a textview and there'sno way to scroll to top.
Every time I make an ajustments to the storyboard view to fit the iPhone 4, the view on iPhone 5 instead looks weird. Most of the time, the stacked objects on iPhone 4 simulator can't even be unstacked.
Am I the only one experiencing this? I cant find any post about it. Could it be that there's something messed up with my simulator? Any setting I've missed? The only solution I can think of now is to have a seperate SB for iP4 and iP5, but I really would rather not go through the pain of doing that. Any comment or idea is greatly appreciated.
How it looks
You need to make sure that your autosizing struts and springs are set appropriately.
The views need to either dock to the top, or bottom and the views that you want to stretch should have the flexible vertical set.

Converting an iPhone app to universal; bounds vs frames

I'm trying to convert an iPhone application to work universally (on both iPhones and iPads). I've managed to get the frame to re-size correctly, but it seems like the bounds (the part the user can actually interact with) isn't re-sizing appropriately with it. So, for instance, a UIWebView will be drawn in the correct dimensions, but I can only interact with it within a smaller confine the size of an iPhone screen.
Any thoughts what's going on?
How are you re-sizing this view? Is it in an xib with autoresizing mask set to properly expand? If so something else is going wrong. I just tried making a sample project with a webview, where the xib is sized for iPhone. I then marked the application as universal, and it runs just fine in the iPad simulator with all areas touchable.

Cocos2d IPhone sprite problem

The problem is - when i load game on iphone some sprites are shown, some are not, plus CCBitmapFontAtlas labels and CCMenu button are also not visible and when i tap on the place where button have to be - there is no effect. At simulator it worked just fine. What is the reason of such strange situation?
IPad aslo works ok.
Hard to say without more detail, but it could be some issue with your build. Try cleaning your targets and republishing to make sure that your iPhone device has the exact files you want it to have. The behavior you describe could come from older versions of image files being used (say, an Atlas sprite going to a frame that used to be blank but has content in the new version).

Best way to create Default.png image for iPhone app

Originally I though I'll just take a screenshot of my app on the iPhone then tweak it in Photoshop.
The images should be 480 x 320 according to Apple doc, and the dimensions of my screenshot are 480 x 320. But, the screenshot contains notification area (where reception bars, battery life, etc. are displayed)
So, if I chop that part off my image will be a bit shorter and not 480px high.
What do I do? Submit a shorter image? Stretch it up so it's 480px but without the notification bar? Submit it with the notification bar in the image?
How did you create your Default.png?
There is support in Xcode for creating the default image. With the device connected, open the Organizer (Window > Organizer). Click the Screenshot tab, take a screenshot and click "Save as default image..." Choose your project and bingo jingo, you're done.
You can leave the notification area in the screenshot. The iPhone will draw the real notification bar over it.
iOS 7 update: the iOS 7 Transition Guide explicitly requires this:
Update the launch image to include the status bar area if it doesn’t already do so.
I think the best way to do it is to use the Xcode screenshotter & edit some of the GUI elements out, like the artwork or text on your buttons so people don't get frustrated when pushing 'buttons' on the Default.png doesn't make your app respond.
If you have a status bar, then you should design 320x460 (less 20 pixels).
Though it is correct that you can leave it at 320x480 and have the real status bar paint over the default.png, it will look weird when the phone is in Internet tethering mode or has a call on hold (another 20 pixels).
By cropping to 320x460, it looks better when in tethering mode.
Just edit out the notification area to match the background of the rest of the image. As long as your image is 480x320 you should be fine.
However, if your app takes more than a few seconds to load, you may want to rethink using a screenshot of your app as the startup screen. People might get confused and think the app is finished loading, when in fact it is not. I've seen some apps produce a "stylized" version of their UI in Photoshop, making it clear that it's just an image and not the actual UI.
you should remember that you maybe need also some space for an In-Call status bar or the Tethering status bar. this bar has a height of 20 pixels. Even apple does not make it right. Put a call on hold and start "Photos" or the "Weather" app, then you can see what I mean. To test that you can use the menu "Toggle In-Call Status Bar" in the iPhone Simulator app.
you can use a real 480x320 image if you add the boolean key UIStatusBarHidden to your Info.plist file and set it as true.
Take a screen shot as many of the answers already mention. However, if your screen shot includes the status bar, you should remove it/replace it with a transparent strip instead. It is true that the iPhone will cover this part of Default.png with the current status bar however, if you run the iPhone app on the iPad, you will still be able to see this part of Default.png.
I built a slightly modified version of the initial view in IB, ran the app with that and took a screen shot. That way, everything looks very iPhoney, no Photoshop needed. Don't worry too much about clipping the top, it will mirror how the view actually looks when loaded if more stuff covers it.
Apple recommends something similar to what the user will see when the app loads. E.g. for my Sudoku app, instead of the grid, the default.png shows a "please wait" message. When the app is loaded, that disappears and you see the grid you can interact with. It looks fluid, and it's obvious when it's loading and when you can interact.
Finally, the interface uses some toolbar buttons. In the default.png they are in the disabled state (grey text). When the app is loaded, they are enabled and change color.