iPhone 5 not displaying app properly - iphone

I am testing some old apps on the iPhone 5 simulator. Most of the apps display properly, that is the display centered, maintaining the original iPhone aspect with blank space on the top and bottom.
One of my apps acts differently. It stretches the launch image (an old 2:3 aspect launch image) to the full height top to bottom of the iPhone 5 simulator. Then it snaps the app to the top of the window, as opposed to centering it.
I suspected this had something to do with auto-layout, but as far as I can tell, being new to the concept, it is disabled. As I checked in the file inspector and "use auto layout" is unselected.
Any thoughts? Thanks for reading!

Removing Default-568h#2x.png from the project should solve the problem. It seems like several people have been having a problem with Xcode auto-creating this launch image.

From my experience it looks like when you open a project in XCode 4.5 it automatically adds a flag to each view saying "Autoresize subviews" and by default this is set to true. When I disable this flag for all my views, they no longer stretch. Interestingly though, I don't get the letterboxing in the simulator, instead a get a white band at the bottom.

I ended up manually setting up the views for the iPhone 5 because I could not locate or fix the issue. Setting up the views specifically for the iPhone 5 was relatively easy, but frustrating to not know why it was necessary in this case.
I detected the iPhone 5 using the code below found in this stack overflow answer: How to detect iPhone 5 (widescreen devices)?
#define IS_IPHONE_5 ( [ [ UIScreen mainScreen ] bounds ].size.height > 500)
if (IS_IPHONE_5 ) {
//set up views
}

Remove the Default-568h#2x.png from the project, and also, you must manually remove the app from the simulator before running it again from Xcode. It looks like ios6 saves some kind of a flag for the installed apps that makes it think it should stretch it.

Simply removing the Default-568h#2x.png did not solve my problem.
First I deleted this file, than I drag a 640x1136 image to the "Launch images - Retina (4-inch)" of "iPhone Deployment Info" section in Xcode.

In iOS 7 Sdk if your are not added launch image in your project you need to
Add launch image (640 X 1136 and 640 X 960)into your project, Then go to General Tab and set both launch image (Retina, Retina 4 inch) then remove app from simulator and run again should solve the problem

Related

App launches in full screen in simulator, but not on device

This is an Xcode 6 Swift project. When choosing iPhone 5 or 5s in the simulator, the app launches at full screen height. However, when running the app on an actual device (an iPhone 5s), the screen is only iPhone 4 in height (i.e. black bars appear at the top and bottom of the screen).
The strange thing is that I've re-created this project from another test project - and in the original project I didn't have this problem.
I've performed a text-compare on the storyboard xml files for each, and both are mostly identical. I've also looked at the Build Settings for each, and can't see any obvious differences. Finally, the json files specified in the "Images.xcassets" directory for each are the same.
Managed to fix the problem. In the General settings for the target, under "App Icons and Launch Images" I clicked the "Use Asset Catalog" button and followed the options.
Place the Launch screen images for both iphone 5 and iphone 4 . Put the size of the default-568#2x image as 640 x 1136 .
May be you missed this size of splash screen in your project.
For me it was fixed after adding the images with all sizes
For me, this was because I'd saved the file in photoshop format, but with a PNG extension. The emulator loaded the file, but the actual device couldn't. Wasted 3 hours messing with asset catalogs before I figured it out!
Blog post on subject

Black screen instead of launch image on iPad

I am developing an iPhone app for iOS 6.1 and 7 (using Xcode 5). I have a problem with iPad launch images.
On iPad 7.0 and 7.0.2, the launch image is not showing up(in 6.1 works!): I get black screen while app is loading.
I don't face this issue with iPhone 6.1 and 7.0.2, although I set all launch images required for iPad and iPad retina (landscape and portrait) and I use Asset Catalog.
What am I missing?
Recently I faced same issue with my App designed only for iPhone , I had the problem where the launch images would not appear in iPad (On iPad ios >= 7.0.x the launch image is not showing up I get black screen while app is loading (in iPad ios < 7.0.x it works fine )).
I don't face this issue of launch image with iPhone worked fine in all iOS versions.
Solution: Is to update to asset catalog to manage your app's images and target only iOS 6 and Prior.
Steps :
Step 1:
Step 2:
Step 3: on the top right corner click on the 'Attribute Inspector' icon. Here you can set the Target OS for the Launch Images.
Uncheck the iOS 7 check boxes for iPhone, Now you should be able to see the launch images for iPad on iOS >= 7.0.x.
If you have the same situation like mine, that's solution:
My app is landscape only, iOs7 only, ipad\iphone (XCode 5).
Problem: black launch on iphone (and simulator), normal launch in ipad.
Solution: go to Images.xcassets - Launch Images - select it. Uncheck at right all "iOs7 and later" boxes. Check "iOs6 and prior" boxes and fill empty spaces with images.
Strange, but works.
Per Apple's documentation (link); an empty iPad specific storyboard may be the answer. I've also seen issues where the initial view controller is not set within a storyboard causes a black screen. A variant of this issue might be an incorrect setting in the app plist.
Technical Q&A QA1780
Why does my app launch to a black screen on iPad?
Q: Why does my app launch to a black screen on iPad?
A: Apps that have been designed only for iPhone may launch to a blank screen when run on an iPad. This is caused by the presence of an empty iPad specific storyboard in the app bundle as well as an iPad specific UIMainStoryboardFile key in the app's Information Property List (Info.plist) file. Both are automatically created by the various Xcode template projects if the Universal option is selected.
...
In Xcode
Look for a file named MainStoryboard_iPad.storyboard in the file navigator. If this file is present, remove it from your project.
In your app's Information Property List
Look for a key named Main storyboard file base name (iPad) or UIMainStoryboardFile~ipad. If this key is present, remove it. You should also remove any other key suffixed with (iPad) or ~ipad.
Finally, test your app on an iPad or in the iPad simulator and verify that it behaves as expected.
I requested Apple support and it turned out that it's a bug. They asked me to report it and I did. Here is the report id : 15340531.
Now it's up to them.
Using LaunchScreen.storyboard
I was having a similar problem until I found the following settings in the General Project Settings.
Set your Main Interface to your main storyboard file. Mine is called Main.storyboard.
Set your Launch Screen File to your launch screen storyboard file. Mine is called LaunchScreen.storyboard. (This is what I had originally ommited.)
After that the launch screen loaded first and then the main story board loaded shortly later.
Try set the image again make sure that resolution of the splash screen is according to the iOS 7 guidelines
I know this sounds stupid. I've had bugs like that when I saved a file in psd-format with a jpg extension. Just 1 wrong click while saving your launch image.
After having tried several solutions found here, I suspected that the iPhone was trying to launch in Landscape orientation, and thus not finding any corresponding launch image. Indeed, the simulator was starting in Landscape for a reason I was not understanding.
Finally, after reading Apple documentation, I found that it's probably the order of keys in "Supported interface orientations" of the info.plist file that was not adequate. The Portrait was the last item. When it's the first item, the app launch in Portrait mode and find the image.
Remove previously installed app from the device or simulator, Then relaunch the app after clean.
I had the problem where the launch images would no appear in iPhone (3.5 or 4 inch) in iOS 7, but the iPad had no problems with iOS 7.
Long story short is I disabled the asset catalog for the launch images only. So I'm adding the launch images the old fashioned way. That seems to have solved the problem.
I will have to do more testing tomorrow, but it seems the problem is solved (at least in my case).
in Xcode 5 , make sure thay you add all needed images mentioned in your app target.
I am assuming that when you are using Asset Catalog, you have ensured that you have the Images.xcassets target membership added correctly. I am mentioning this since if you have multiple targets, looks like you have to add them manually (and you have not provided any screenshots so one can be sure).
Now that you have not really provided a screenshot of the "LaunchImage" overview of Images.xcassets folder in your project, I can only guess the probable reason. Looking at the fact that the launch images work fine for iPhone (6.1 & 7.0.2 and iPad (6.1) and do not work only for iPad (7.0 and upwards), I think you could perhaps look at as to whether the dimension of the images for iPad Portrait and iPad Landscape are proper for iOS7. Specifically, you should see your launch images and not empty rectangles as seen in the attached pic-
This can happen due to the fact that you still have the iPad launch images for iOS7 created excluding the status bar area. Prior to iOS7, the iPad launch images were created to exclude the status bar area, but it's a must on iOS7 that all the launch images must include the status bar area. Please go through the section "Things Every App Must Do" in Apple iOS7 UI transition Guide (https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/TransitionGuide.pdf).
The following screenshot should explain what I am talking about-
e.g. you can see that iPad Landscape Retina image dimension for iOS6.1 and previous is 2048x1496 (excluding 40 px for status bar) but the dimension for the same image for iOS7.0 and upwards is expected to be 2048x1536 (including the 40px for status bar). So, if you have not changed your images accordingly, you will see black screen for images on iPad 7.0 and upwards. On iPhones, you will not face this issue since iPhone launch images always cover the status bar, be it iOS6.0 and iOS7.0- so the new UI requirement is already met for iPhone launch images.
I found this answer which worked for our app (iPhone only, but used on iPad): https://stackoverflow.com/a/19448782/1258419
To summarize from that answer:
How to do it. Go to the asset catalog. And on the top right corner click on the 'Attribute Inspector' icon. Here you can set the Target OS for the Launch Images. Uncheck the iOS 7 check boxes for iPhone. Now you should be able to see the launch images for these devices.
I encountered a similar problem in landscape, my iOS 7 launch image wasn’t displayed while the iOS 6 did. Mine was the iPhone Retina 3.5” launch image.
Since I have another app in portrait that didn’t share this issue, I did 2 things:
In info.plist, under “Supported interface orientations”, I added the
2 portrait modes as well, and put them before the landscape, like
this:
Item 0: Portrait (top home button)
Item 1: Portrait (bottom home button)
Item 2: Landscape (right home button)
Item 3: Landscape (left home button)
Implemented this method in the View Controller:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
This works with or without the Asset Catalog.
This is an update for iOS 8.
I got the same problem when I tried to add a LaunchImage to my iOS 8 app.
Apple enables developers to use a xib, whose default name is LaunchScreen.xib, to render the launch view as of iOS 8. I believe developers can use either LaunchImage or LaunchScreen.xib. Unfortunately, I couldn't find any document describing how to deal with LaunchImage after LaunchScreen.xib was introduced. I always got a black screen when I tried to use LaunchImage as the launch view.
My solution is:
Don't think about LaunchImage. Use LaunchScreen.xib. (You have to keep an empty LaunchImage in your Asset Catalog though. I believe it's a bug.)
Drag an UIImageView to the xib and make the UIImageView full screen. Remember to take the size classes and constraints into account.
Set an image whose resolution is enough for iPhone 6 plus to the UIImageView.
Check your all images and see if it is properly placed in the Asset and properly named and sized.
Also check which orientations your are allowing and accordingly add images to the asset.
I had the same problem.
I had to make a workaround: used the Default image for all iOS versions and DELETED the UILaunchImageFile key from info.plist.
I cannot use different launch images for iOS 7 and previous versions, so, I had to use the same "artistic" image for all, instead an image that mimic the first view of the app (which Apple recommends and I prefer), but at least I do not get the black screen anymore.
It looks like the UILaunchImageFile key that allows to use differents launch images for iOS 7 and previous versions is not working properly for Retina iPad in iOS 7.
WARNING: I am still testing the app, so I don't know if could be some side effects.
I also faced the similar issue but its solution was simple (in my case).
All I did was following -
1.Add a new file (if you have not added it) Launchscreen.storyboard
2.Get a UIViewController, mark it as Is Initial View Controller then add a UIImageView in it and set a picture which you want to display during launch of your app. Make sure you give this UIImageView required constraint.
3.Go to Project->General->App Icons and Launch images and select Launchscreen.storyboard as Launch Screen File (There will be a dropdown for it).
Because of iOS 13 and later, app launch different than earlier versions.
Get the solution from below URL.
https://stackoverflow.com/a/59913274/883505
I simply forgot to call super.loadView() in my view controller...
override func loadView() {
super.loadView()
}

Black bars showing when running app on iOS 7 (4 inch retina display)

We have an iPod app built with base SDK as 5.1.
App has a tabBarController with three tabs and each tab has a UIViewController to load a different view.
The app works fine for iOS 6.1 and iOS 7 (3.5 inch display) simulator and device but when we run the app on
iOS 7 (4 inch display simulator) or device we are getting black bars at the top and bottom of the view screen in all three tabs.
If anyone can suggest reason for this or some feasible solution to this problem, it would be really helpful for us.
Thanks
First thing is that you must add the required default image for 4 inch screen display. Check Properly in you project have image with name Default-568h#2x.png (640 × 1136 pixels)
This Default-568h#2x.png is Necessary for Support app in 4 inch Screen display
Ones you add this image in to you working Project, Remove old Build from device or Simulatore, clear Project and re build and check Hope you issue will solve.
Edit:-
After fix the black Bar issue you can check the device like my answer Give here check this:-
Detect device type
you have two choice if you can't use AutoLayout
First
Create two xib with same class one for 3.5 inch screen and one for 4 inch screen set using macro with checking which screen appear.
Second
Set Self.view frame using macro with checking which screen appear.
There are also other methods you can use for set self.view frame as using window frame or UIScreen
My problem was I accidentally deleted the value found here:
I added back LaunchScreen, and made sure there was a LaunchScreen.xib. Maybe it will help some others.
Ive had the same problem - black bars at the top and bottom. It was simply solved by setting the drop down in "App Icons and Launch Images" to Main_iPhone:
App Icons and Launch Images Screen Shot
I was facing same problem . I just added launch image and it worked for me.
XCode->Click on Project File -> Select Target-> App Icons and Launch Images -> Add launch image source
This worked!
Pay attention to Step#5 and Step#6 below:
1.In xcode, Click on the Project file in Project Navigator
2.Click General tab
3.Type "Main_iPhone" in the Launch Screen File field
4.Save
5.Remove the app from device or simulator
6.Then in Xcode go to Product Menu and then select Clean
7.Build again

App runs on iphone 5 like iphone 4

I have finally done to build Augmented Reality app.
The app works great for iphone 4 screen size Width :480 Height :320.
During the development I have also test the simulator to see launch goes well for 4 inch display (iphone 5), and it did go well the splash screen show was the 4 inch png named : Default-568h#2x.png and the screen shows a white background fully (like it should).
When I launch the app on a real iphone 5 device, the 3.5 inch splash screen loaded and the app load like it loads on iphone 4. Everything in the middle and I get a little black equal Margins from the side, the cable is original and this is the Weirdest thing ever happened to me.
UPDATE : i have also tried to add this code on the simulator and to the real device :
CGRect bounds = [[UIScreen mainScreen]bounds];
NSLog(#"%#",NSStringFromCGRect(bounds));
the simulator prints iphone 5 screen size, the real device prints iphone 4 size.
Any help please
Make sure you have all three Launch images set up correctly. :)
Make sure the image has been added to the target.
=> If you select your image file in the Project Navigator (left pane) the Utilities pane (right pane) should have a checkmark under 'Target Membership' next to your target.
I think that your views need to resize. You may need to include some code that detects what device the person is using and resizes the view. Just a suggestion.

Black lines on iPhone5 with old apps

I got an old app, wich is compatible with 3.5 inch displays, like on iPhone4S and older.
This is app's screen:
When i tried run this app on iPhone5 simulator it looks really bad!
Apple promis that all old apps will appear with black lines on top and bottom! How should i do it? I don't want to refactor all my code from xib files.
Thanks
Did you add launch images (like Default-568h#2x.png) for your app? This will signal iOS to stretch the app to the full display. Apps without will be displayed with black borders at the top and bottom.
Also see this question + answer on how to fix this:
Undo auto resizing for iPhone 5 screen after adding Default-568h#2x.png