image view only shows background color in launch screen - ios

I'm having some problems with my app's launch screen storyboard.
When I run the app on an iPhone 5S, the image is displayed. However, when I run the app on an iPhone 8, the background color of the UIImageView is shown.
In the project settings, at App Icons and Launch Images, I am not using an image source (although trying do so doesn't seem to work either) and the Launch Screen File is set to LaunchScreen.
The View Controller has Is Initial View Controller checked and the file has Use as Launch Screen checked. The image set was brought in using Import... and is universal.
I've read through several of the solutions for black screen here, but switching the background color revealed that was where my black screen was coming from.
In the assets file, the image set has 1x # 640x1136, 2x # 1242x2208 & 3x # 1125x2436. I experimented with other combinations, but this is the first set that let me see the actual image on the 5S. I'm pretty sure the issue is not having the right configuration of dimensions in the image set file, but can't be certain.
Any help would be much appreciated. Thanks in advance.

Had the same thing. Working on the simulator but didn't work on the device (or any other possible option). It's just a bug.
Try these until it works:
Turn simulator/device off and then on again.
Hard clean simulator. Turn it off.
Clean/Hard Clean/Delete Derived data
Reboot Xcode
Hope one of these helps.
If not, please include the screenshots of working / non-working app screens.

Related

Launch Screen not working on iOS 14 with Xcode 12

I am very frustrated now. I upgraded Xcode to version 12 and tested my app on iOS 14. Now the problem is, that my launch screen is just showing in black. I tested it with an iOS 13.5 device and it is still working as expected. I tried to remove the launchscreen.storyboard approach and added the Launch Screen key in the info.plist, but then the image is scaled to full size.
Now I tested a little bit with the launchscreen.storyboard and I found a few things.
If I remove the Image view, the launch screen is showing as expected. I added just a label and that would work.
If I use an image from the system in the image view, it is working as well. It is just not working when I am using an image from the project.
Did you experience issues with iOS 14 and the storyboard approach?
If yes, how did you fix it?
A work around that seems to be working for me:
For a strange reason if I am downsizing the image then it is working fine. I had a full size image of dimension 2732x2732 and it didn't work. Reducing the dimension of the same image to 2400x2400 is working fine. I have tried with 2500x2500 and 2600x2600 but none worked.
Most importantly, every time I change the image I had to restart the simulator to reflect the updated image.
It didn't work on the real device yet. Like the simulator, I had to restart the device and then only it worked.
Not sure if it is something with the dimension/size of the image or with the reboot.
Further updates:
I uploaded the same build (with smaller image) to TestFlight and installed it on my device (basically updated from the previous version having large size image) and unfortunately the issue persisted :(
Now what I did is uninstalled the app and reinstalled it again from TestFlight. Issue still persisted.
Finally I had to delete the app, reboot my device and install the app again. This is when it worked fine.
So here are a lot of good ideas, but I was able to finally solve the issue - it is more like a workaround. I needed to store the picture outside the Images.xcassets folder and then it started to work again. This is a very weird issue.
A workaround is to use a button with an image instead of an imageview in the launch storyboard. It works like a charm!!
One reason might be the size of the images. Since iOS 14 images for launch screen are limited to 25 MB as stated in Apples Human Interface Guidelines.
An image with 2.400x2.400 pixel will result in a memory size about 22 MB. With 2.500x2.500 we reach the 25 MB.
We had the same problem where the full screen image in LaunchScreen.storyboard was black on all #3x devices like iPhone 12. Reducing the size of only the #3x launch image from 3.072x3.072 to 2.400x2.400 solved this problem.
A square image is the easy way to support landscape and portrait orientation. But it should also work to have different images for each orientation, where one image in total is less than 25 MB.
Had the same problem. The issue was the .png image used in the launch screen storyboard. This lead to the whole launch screen just being black.
What fixed it in our case was:
Choose a smaller image
Delete App from device/simulator
Restart device/simulator
I found that the image was the source of error by replacing the image with an other one in our app. It immediately worked with a different image (no restarting or else required).
The only workaround that works for me was to add the images outside Images.xcassets folder. After modified this and rebuild the app, it worked expected.
Some issue it's happening on the iOS 14 or XCode 12.
I encountered this problem
when using LaunchScreen.storyboard and used the image on Assets.xcassets, not working on iOS 14 with Xcode 12.
I solved it by try put change 3x image 2436×1125,and set 2x image 828×1792.
Finally I had to delete the app, reboot my device and install the app again. This is when it worked fine.
I had this, too. Pretty infuriating. My launch screen is merely a background image (2048x2048 PNG) and a graphic (2048x2048 PNG) in the middle.
The fix for me was to have a smaller middle graphic (720x720 PNG), remove the images from any assets catalogs, and add them into the project.
The images didn't show on the Simulator until I restarted it. When built and installed to my iPhone, I didn't have to restart it.
In my case, the ViewController property, "Is Initial View Controller" was not checked. Also, be sure to set the color of the view to an actual color and not a system color, otherwise you can run into issues with the device theme settings. That is, if you like to show a specific color.
Also, to access that setting make sure you click on the actual View Controller object in the drop down panel.
The only thing that worked for me was:
Delete the existing LaunchScreen.storyboard & create a new one
Check " Use as Launch Screen "
Check " Is Initial View Controller "
Make sure the image your using is NOT located under Assets.xcassets folder. I put my image in the root of the project
Delete the app, restart the simulator, and run the application
BINGO!!!
I have a similar issue with XCode12 / iOS14 and React project:
The launchscreen.storyboard was working fine in previous versions. Since update to XCode12 it shows as following:
Lauching into a black screen (2-3 seconds)
Then showing the Launchscreen correctly
If I try to use the new "Launch Screen" dictionary in Info.plist I have the follwing issues (same in another Xamarin App):
Image is zoomed in / not showing completely
Background color setting is completely ignored (tried RGB and Color.xcasset)
This is just completely bugged since Xcode 12 !
So I've had this bugged with Apple via their feedback system since June 26th 2020 - FB7795777.
I've provided my project and many diagnostic reports and they've never come back with a fix.
However, today, I fixed it.
Basically, there has been some change in the iOS/iPadOS SDK about how it's support .PNG and .JPG files (size or dimensions are the problems I think) in the Launch screen process.
The solution:
Open your .PNG file in Photoshop and re-export it with the 'Smaller File - 8-bit' option checked. It shrunk it down to less than half the size, and it worked first time.
In my case following did the job:-
Remove Launch screen file from Project -> General -> App Icons and Launch Imagees -> Launch screen file.
Go to info.plist file and open as source code.
Add following code there and change the image name:-
<key>UILaunchScreen</key> <dict> <key>UIImageName</key> <string>splash(This is your image name)</string> </dict>
In iOS 14 this new key was released (UILaunchScreen). So take care from next time. If you get error then check info.plist file.
Happy coding :)
That worked for me was:
Put xxx.pdf image into Assets.xcassets and set "scale" to Single Scale
In Launch Screen.storyboard, set the imageView's image is xxx, then set imageView's width, height, centerX and Bottom to View
Then worked for me
Xcode 12.5.1, iPhone 7 Plus, iOS 14.6
In my own case , I solved the problem in these few steps:
Image must be 1024px, then
Add to assets
-> A workaround in case you have a much bigger image, use these simple steps:
Generate your app icon
Go to the app icon folder
Copy the 1024 px of that image andappicon image
Then add to assets.
Both methods works perfectly.
This may help others so I am adding it here.
I use Cordova for my hybrid app, and then I load my image assets that are generated by Asset Catalog Creator (which is a great little product).
This was working perfectly until I updated to Xcode 12 and tried to run it under iOS 14.
What I discovered is that Cordova was adding a "CDVLaunchScreen.storyboard", and they had a "LaunchStoryboard.imageset" (directory) in their asset catalog, which contained just a contents.json file.
I simply copied this into my asset catalog, and when I drag and drop this into my updated project (newly generated each time by Cordova), my Launch Image displays again.
Don't ask my how or why Xcode magically wires this stuff together, but it worked for me.
I can pass along the contents.json that worked with my asset catalog if it will help.
BTW, my General settings screen does NOT have a Launch Screen File selected, but Xcode seems to find the required files.
I've got yet another potential solution to this, as none of the existing solutions worked for me.
I use PDF vectors in my Asset file, and this normally works great. But it turns out that it doesn't work on the launch screen - it just shows skips the launch screen entirely if it contains a PDF image.
Swapped it for a large PNG, problem solved.
What worked for me:
Use smaller images like #Darkpaw suggested. Launch storyboards are, after all, intended to be indicative of the coming UI, not artwork based.
Use PNG image (not PDF) and don't put it in an assets catalog like suggested by #Sylber
Just noting separately as I had black/broken launch mages until I did BOTH steps.
You might be seeing this issue if your #1x, #2x, #3x images are blank in your image xcassets folder.
Make sure you have images for each.
You can also select your 1 image, and set Scales as "Single Scale" in the Attributes inspector (on the right hand side)
In Xcode 13 launch screen was not displaying rather a black screen was coming.
But this worked for me Project -> General -> App Icons and Launch Images -> Launch screen file -> change Main to Launchscreen.
Most answers mentioned here are workarounds, the issue i noticed is that when you modify the launch screen assets, do check the item file name too.
Assets -> Show in folder
Then check the launchscreen items folder and make sure that the item inside the folder has the same name as folder.
To expand on Thorsten Stark's answer above...
Since iOS 14 images for launch screen are limited to 25 MB
For me it appeared to be an accumulated size of assets on my Launch Screen storyboard file. When I removed a number of them I no longer saw the black screen.
I ended up just using one image 2778 x 1284 which was 600kb in size. This solved the problem.
To further test, I duplicated the image to make 3 copies on my Launch Screen storyboard file, and sure enough, black screen again.
The best solution to me in 2022...
reduce sizes of your images, in my case:
splash.png (256x256)
splash#x2.png (512x512)
splash#x3.png (768x768)
only doing this and put them in Resources folder then reference in
ImageView work like charm....
alternative:
use Button in place of ImageView works too

Black bar appears on top when running on iPhone 6 & iPad Pro Simulator

When I run my game on the simulator, specifically on iPhone 6 and iPad Pro, it shows black bar on top of the screen. I have looked the answer up online and have literally tried every single thing and have went through all the answers, but none have worked. My deployment is set to 7.0 and have tried running with setting just set to LaunchImage from asset folder and LaunchImage & LaunchScreen.xib combined. I also do have the right size pictures required in asset including iPhone Retina 4, as well, and that doesn't fix the problem either. Is this just a glitch on the simulator or there is a way around this?
I got it working. For some reason my 2x images were short for the screen size, and had to extend them more. Even though height wise, my images had more length than the screen size.
Hope this helps people. I came across several people who had done everthing right, but still couldn't get it working. I believe it is because image isn't large enough to cover the whole screen
Stretched mode?
Are you providing Default screens in all sizes as suggested in:
Dealing with iPhone 6/6+ startup images
How to Update Your Apps for the 4-Inch iPhone 5 Display
Restoring integrity in Startup screens
Images clipped?
If not running in stretched mode, pick a View Mode best suited for your images, such as Aspect Fill and Scale to Fill, both of which will cover your UIImageView in LaunchScreen.storyboard.
Add Default-568h#2x.png Image with resolution 640x1136.
Make sure 'App Icons and Launch Images' look like below image:
it worked in simulator with iOS 9.

iOS 9 xCode 7 built app displays black rectangle instead of splash screen

I know this question may seem like a duplicate of a few existing ones but its not.
I am struggling with this issue where universal (iPad/iPhone) application does not display the splash screen anymore.
Before upgrading to iOS 9 and Xcode 7, no such issues were present. After upgrading no changes were made to the splash screen in any way.
Tech data relevant to the question:
Supported devices are iPad (landscape only) and iPhone
(portrait/landscape)
I use "Launch Screen.xib" that has an UIImageView with size classes and
constraints set up so that it's always full screen.
I have added all splash screen images in image assets (except iPad
Portrait ones)
I use Xcode Version 7.0.1 (7A1001) and iOS 9.0.2
This issue does not happen on an iPad
The wrong splash screen looks like this on iPhone 5s:
This is made in portrait mode, so there are white squares on top and on bottom of this "black square".
I was struggling with this issue yesterday but I managed to fix it by renaming my launch screen to "LaunchScreen.xib" (without the space). But this morning the issue re-appeared.
Things I've tried:
Removing and creating LaunchScreen.xib again with and without space
Creating LaunchScreen.storyboard file instead of xib
Adding #2x and #3x versions of image used in LaunchScreen.xib
Removing/adding/replacing images in image assets
Cleaning, build cleaning and even deleted derived data
Restarting device, reinstalling app, relaunching without building and many other solutions that I could think of.
Nothing helped, so maybe someone fixed a similar issue already and can lead me to the right direction.
EDIT 1
So I renamed my LaunchScreen.xib image used from "Default.png" to "DefaultSplash.png". This instantly fixed all issues on iPhone. But now I have a new problem - iPad splashscreen is now black. If I set the LaunchScreen image to some other image used in project, the Ipad displays it as splashscreen without any problems, but neither Default.png nor DefaultSplash.png can be used on ipad now. This is really weird issue.
In my case the images in the "Launch Screen.xib" weren't displaying. I had to rename them and reset the new names in the nib file to make it work.
So I fixed the issue like this:
Since I renamed the file LaunchScreen.xib, it fixed an issue on iPhone but caused a similar problem on iPad. Since then, I cannot use the same image file name for the same xib (i.e. if image "Default.png" failed, it cannot be used anyomre... Bug?). So I created two files, LaunchScreen.xib and LaunchScreen~iphone.xib with separate image files for each. Now it works okay.
Seems ugly and buggy but it works.
There is a change in Xcode7 iOS 9 onwards. They have modified Launchscreen(Black screen we will get).If you change deployment target means you can see the previous launch screen. Only empty view controller is present so we have make changes on it.
As per requirement in assets add images in imagecassets.
It may sound stupid but something related to this scenario may happen:
If you hook any outlet and then break it by changing the custom class you will get this black screen behavior without any warning, instead of the typical crash from any non launch storyboard/scenes this will lead to a black screen before the app start.

iPhone 6 - app does not fill screen

Most of my apps scale up when run on an iPhone 6, but for some reason one of my apps looks like this:
What would cause it to not just scale up and fill the screen?
EDIT: Here are some repro steps:
Create a new project (Single View). Turn off size classes and just use iPhone.
Make the background orange.
Add a yellow UIView subview at (20,20,280,200).
In Xcode you get this:
Now simulate on iPhone 6. You get this:
Why doesn't it just scale up and look normal?
Not sure why this is getting downvoted. It's a legitimate question. And here's the legitimate answer:
Remove the "Launch Screen File" in Projects > General. Xcode 5 did not have this so older apps scale up automatically. Apps created with Xcode 6 get a default Launch Screen file created.
Removing it will make your app scale up on iPhone 6.
I have got the same problem and I managed to solve it by adding constraints to my ViewController in the storyboard.
Make sure that you clicked the ViewController of your scene. They yellow button in the this screenshot.
Click Editor-> Resolve Auto Layout issues -> Add Missing Constraints
Now you will find that the background image is scaled up to fill iPhone 6 or iPhone 6 plus.
Note that this solution works for me even if I did not provide any launch screen file.
I had the same issue. Searching for an answer, most of them mention the launch image. To me, what did the trick, was that I first enabled launch image for iOS8.0 and later in Xcode, which requires the native resolution sizes for 4.7" and 5.5". Adding these sizes didn't help, but when I re-disabled them, it started working!
If you do have any launch image, you will need launch images for all appropriate sizes. I was doing a minor update to an app, and it was not showing correctly on the iPhone 6 simulator. I created four launch images (.png files). Since the app should still run on iOS 7, I apparently could not use an asset catalog. I gave the images the correct names, and all is good.
Image sizes and names may be found here:
Sizes and Naming of Launch Image for iPhone app in iOS8

Splash screen coming in inverted way?

When i created App the launch image was correct and now its almost a month but when i run the app in device and simulator the splash screen is just inverted!!! i don't know why ???
Please check the attached images,Images are correct but when they
appear inside device or simulator its inverted
I have tried to remove the images and add it gain ,its not working .
Then i have created a new asset catalogs and added corresponding images.But now in iPad 3 its coming correct but iPhone its still wrong
Go to your plist file and look for Supported interface orientations (iPhone)
you will see some thing like the below attached image.
Make sure the sequence of the orientation levels is as shown in the above screen shot.
It worked for me. give it a try.

Resources