UIImageView not loading image on all devices - ios

This is my first time posting a questions here. So far I have been able to find the solution to all issues I have had. For 2 weeks now I'm struggling with a strange issue.
Issue Description:
I'm developing an universal application for iOS 5+. I'm having an issue with one image, which is not displayed everywhere. This is my background image and it displays correctly on all iPhones (3GS, 4, 4S, 5) and iPad retina. Unfortunately there are 3 screens on which it doesn't displays. This happens only on iPad without Retina display. The images appears on the other screens and I can't determine what is different so it doesn't display on these 3 screens.
What have I tested:
I have tried to delete the image and add it again - nothing changes.
I have double checked the naming of the file - everything is fine.
I have tried to load the image in another view controller and it loads.
I have cleaned my application and deleted it from all devices - issue stays.
If you happen to have any suggestions on what can be the cause of that strange behavior please give me a hint.

OK, since your image is already in the project and the target, here's a couple of other reasons which could cause the issue
The file extension and the type of file don't match. Try saving the in another format and use it in the app. See if that works
You mentioned this is a universal app? Are you naming the images correctly (image.png, image#2x.png, image~ipad.png and image#2x~ipad.png

Related

AppIcon not being shown

May app has two storyboards, where the default Main.storyboard is used for iPad, and another one named iPhone.storyboard is used for iPhone build. The storyboard to be used by the app is chosen in AppDelegate, in application didFinishLaunchingWithOptions after detecting which device is running the app.
For me, this two storyboard approach is very much simpler than working with adaptive layout, because of my app characteristics. But there is one side effect I couldn't overcome until now: when the app is installed on iPhone, the app icon is not being shown, even though I have the icon images for iPhone in Assets.xcassets. On iPad the icon is being shown correctly. Any ideas?
I have just discovered that I was using a wrong sized image for the icon. I had two separate projects for iPhone and iPad before. Funny that I made the same mistake then, but the iPhone app icon was shown anyway. I also made this mistake for iPad in this new joint project, but, as I mentioned before, I had no problem with the iPad icon. Sorry for bothering with this silly question.

App compiled with Xcode 6 runs on iPhone 5s top/bottom of screen blank

Recently we switched to Xcode 6, and I am having this issue: my simplest tabbed app compiled with Xcode 6 occupies just part of the screen, when it runs on iPhone 5s. There are two black strips sitting at the top and bottom of the screen. Like below:
By default, it looks that way (that is, I created the project using Xcode's template, and compiled and ran it without any modifications). I have also tinkered with various project setting bits, but in vain. Tried creating the project in both Swift and OC, both had the same issue. Never had this problem in Xcode 5.
Can anyone tell what's going on here?
Thanks.
Set up launch images in your app. It is mandatory now for ios 9. Refer this https://stackoverflow.com/a/18913189/3051458
This happens when you dont have the right image assets in your project.
Correctly again drag drop the correct image assets in your project (check the splash images) and it will work.
Dont know why this happened but I suffered from this too ones and then saw the splash images got deleted.

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.

UIImageView missing images in Launch Screen on device

I have an app that supports iOS8 and later, built in Xcode 7 and I am using a XIB for a Launch Screen (I do not have launch images). The view contains a single UILabel with the app version, and 2 UIImageViews with images that are both present in Images.xcassets: A logo and a splash image.
The UILabel and the logo image appear correctly when I launch the application, but the splash image does not if I run the app on an iPad Air 2 with iOS9. I have tested on an Air and a Mini running iOS8, and iOS9 simulators for iPad 2, iPad Air, and iPad Air 2 and the image appears correctly in all of those.
I ran some basic troubleshooting to see if I could figure out what is going on but I haven't been able to solve it and the only difference I can see between the image that's working and the one that's failing is when I added it to the assets...
Here's a rundown of what I know:
The UIImageView for the splash image is in the correct place, at the correct size. I can tell this because I set its background color to green just to make sure. The view is there, but the image does not appear. So I'm assuming that the view is not to blame.
Setting the UIImageView for the splash image to also use the logo image makes the logo image appear in the correct place for the view. This also leads me to assume that the view is not to blame.
The UIImage that I am using in the splash image view is used elsewhere in the app and appears fine in those other views (the logo image is also used elsewhere in the app and appears fine). So I'm assuming that the image is valid and having it appear in other views is not a problem.
I've confirmed that the settings of the UIImages for the logo and splash in the xcassets file are the same. They are set to Universal, Any width and height, multiple scale factors, rendered as default. There is one difference - the logo has 1x, 2x and 3x scales while the splash image only has 1x and 2x, but I have also tried using UIImages with only 1x, and 1x and 2x values in the UIView and they work (if they were added to the project some time ago).
Adding another image of a different size or format (PNG and JPG) to my xcassets and using that UIImage in the UIImageView for the splash image also fails to display.
Adding another UIImageView to the XIB file and allocating it a UIImage that was already in the xcassets works, the image appears in the loading screen.
Copying and renaming the image files used for the logo and adding them to the project then using that UIImage in the splash view also fails to display.
I have tried cleaning the project, restarting the development machine, and deleting the app from the Air 2 and reinstalling it just in case that was a problem.
These last three steps lead me to believe that there's some issue with images added after a certain point in the project file's lifetime. While I updated to Xcode 7 yesterday, the splash image was originally added in Xcode 6, but the logo image (also added in Xcode 6) was added some months before.
I've looked over the json files for the logo image and splash image and they appear to have the same format. I've also trawled through the pbxproj file looking for differences and I can't see any.
So I was wondering if anyone had any idea why the launch screen might not display these new images I'm adding on the Air 2 specifically? Other questions I've been reading through relating to images not appearing all seem to relate either to Launch Images, or to images in XIB files that have associated classes, neither of which seems relevant here.
Turn it off and then on again.
Seriously, restart the device — that’s what fixed it for me.
Here’s what didn’t work:
Cleaning DerivedData.
Cleaning the project.
Uninstalling the app from the device.
Restarting Xcode.
Restarting the computer.
Older observations:
Just like the others, it:
Works fine in the Simulator
Used to work on the devices (iPhone 5S, iPad Air)
No code changes (verified via git reset --hard HEAD), yet stopped working.
What I remember triggering the first build where it stopped working was unplugging the iPhone while it was runnning. (Not sure if it’s related.)
However, the git reset not fixing it (combined with all the clean steps not working) tells me it this must be getting cached somewhere else. Quite possibly in one of the .gitignored files? (I’m using Git ignore file for Xcode projects)
One workaround that worked for one UIImageView (in the UIView that has three) but not for the others was putting the image into an .xcassets file. Reverting to the plain image file did not undo the fix. (Really feels like a caching error.)
UPDATE: See top — restarting the device is what fixed it. I get the feeling the wrong bitmap data is being cached on the device itself.
Radar: http://openradar.appspot.com/23534818
"The solution for me was simply to make sure that the "Clears Graphics Context" box is unchecked for the UIImageView in the storyboard. Just changing this fixed it for me."
No other solutions worked for me.
Got it from apple developer forum
I had exactly the same issue on an iPhone 6.
The very strange fact is that I was able to use another image from my images.xcassets which had the same size, compression, color space ...
I'm not able to find why it doesn't work but I found a solution :
Simply put your file outside your images.xcassets and use its full name (with extension) in Interface Builder
Hope this help !
The following sequence of operations fixed the issue for me on Xcode 7.3.1 and iOS 9.3.4:
Clean Your Build (⌘+⇧+K)
Close Xcode
Hard Reset iOS Device (Power + Home Button reboot)
Relaunch Xcode - let indexing finish and build on device once it is ready.
Many other answers suggest rebooting devices and / or rebuilding and / or reinstalling is the solution.
While these answers work for some of us, the reason these work is because the app is forced to "retake" or "rebuild" cached snapshots.
Cached snapshots are used by apps to present images before supporting data is loaded into memory, including the asset catalogue that contains storyboard images.
This SO answer by #jaga provides the solution, but not the reason, as to why UIImageViews are missing in the Launch Screen on device (but not in the simulator).
Background
Recently I attempted to use a custom font in my "Launch Screen.storyboard" file.
The reason I could not became clear after reading this SO answer by #TimCamber, which prompted me to do a little more research and testing.
The reason that a custom font is not included in my Launch Screen Storyboard file is the same reason an image within an asset catalogue is not included...
The app prepares portrait & landscape snapshots of the app's Launch Screen from your Launch Screen Storyboard file and (currently) saves it in your app bundle here:
/Library/Caches/Snapshots/<<app_bundle>>/ and
/Library/Caches/Snapshots/<<app_bundle>>/downscaled/.
This process is complete before any supporting files are loaded, including any custom fonts and the asset catalogue.
Solution
As mentioned above by following #jaga's solution, literally all that is required is to:
(old school) add an image file (.PNG) to your app's bundle (as you can see from the screenshot below I added the image file under the Supporting Files subdirectory in an Images subdirectory), and
reference that image in your UIImageView object in the Launch
Screen Storyboard file...
I was seeing the same problem. Rebooting the device (iPhone 6) and rebuilding the app to the device is the only thing that fixed it. I tried many other tips and suggestions but nothing else worked. Only reboot + rebuild helped.
My solution #iOS 11.x:
Use .jpg image instead of .png. I think image file size matters;
(Optionally) Put image file in project directory rather than .xcassets;
I had the same for app installed from TestFlight.
Delete app -> then restart iPhone -> then reinstall app works for me.
Just reinstall app or just restarting device didn't help.
What worked for me was to select Reset Content and Settings... from the Simulator menu
I was having the same problem, but restarting the device didn't help. What worked for me was deleting the UIImageView from my launch storyboard and adding a new one.
Have you tried turning the device off and on again? Do it.
Bring images out of Image.xcassets and add them again to project. It worked for me.
Remove app from mobile and then restart mobile and install app again. now the issues will be solved
I also had this exact problem in Xcode 7 with iPad and iPhone devices. Although it makes no sense, I was able to get around it most of the time by setting not only the Image but also the Highlighted image in the image view to the same image in my images.xcassets.
I use the iPhone 5s device, also meet this problem.
I fix it by :
Remove Drive Data
Clean the project
Restart Xcode
Remove the project from my device
Restart the 5s.
I think it's something wrong of Xcode to use memory, system may be allocate a little memory for Xcode cause Xcode drawing the lunch image failed (On my computer , Xcode have runned for several weeks without close)
it's worked for me.
First in xcode clean de project.
If you use the simulator, delete app and relaunch.
If you use a device, delete app and restart the device.
I think launchscreen only support image in Assets.xcassets.
Restarting Xcode did it for me.
What did not do it:
Clean build folder
Restart device or simulator (image wasn't visible on either)
Select the ImageView and then remove the image extension (.png or .jpg) in the attributes inspector tab > Image view > Image > Image Name.
On launchscreen.storyboard the image will not appear but it will be there in device. This worked for me.
It seemed a bug of iOS. Like sometimes the system animation disappeared.
Now I just reboot the iPhone and it is worked for me.
In my case I it was the image name.
I added an image named Default-568h#2x.png to LaunchScreen.xib - one of my old launch screens just for testing purposes. I was building on the iPhone X Simulator, the image didn't show up.
Changing the name to something neutral (MyImage.png) solved the issue.
It seems that the #2x was part of the problem as well as the -568h.
Which makes some sense on a -812h#3x device.
I have the same issue with imageView a launch screen storyboard. I removed reference of picture from project, I renamed my image and added it again to project. All works perfectly.
Also can 1. delete project image 2. change image name 3. add file image to project
It worked for me.
I had this problem in iOS 10 on an iPhone 6 and also in the Simulator. My image was in a folder and that seemed to be the issue. I removed the image from the folder in Xcode and put it in the project's base directory which solved the problem.
I experience the same. I change image resolution from 300 pixels/inch, change it to 72. It works for me.
Next helped to me:
change "Launch Screen File" to another xib
run the app
change xib back
Also very important: check that your is xib not opened in another tab, that can cause it as well!
I found a simple but radical solution that worked for me :
1 - Delete the file : LaunchScreen.storyboard and move it to trash.
2 - Product -> Clean
3 - Create a new launch screen file named : LaunchScreen.storyboard and put your images in it
4 - Save and build
That worked for me after trying complex methods for hours... It seems that my LaunchScreen.storyboard was write-locked and couldn't be saved or a weird caching process was blocking it.
This is too important
Must be empty! Launch Screen File
Image name is the problem.
Rename the image name used inside the Launch screen storyboard.
Make sure not to use any character other than alphanumeric ( don't use "_-&#")
Worked for me like a charm..
SOLVED!
The only thing that worked for me was deleting the ViewController from LaunchScreen.storyboard and create a new ViewController set to
Is Initial View Controller
Simple as that :)

iOS Universal app seems slightly zoomed in on phone

I have an iPad app that I'm converting to a universal app to show on phones. It has both a tab bar and a navigation bar, and my problem is that they are both way too big on the phone. I could swear I heard Paul Hegarty (from the iTunes U class from Stanford on Swift app development) mention a switch or trick somewhere that would cause the bars to adapt to the iPhone, but I can't find it.
Here are screenshots of my apps bars, vs the Photos app in the iPhone 6 simulator to show what I'm talking about.
Not a huge difference, but significant on a small phone screen.
My fonts are also way to big, which is confusing since I have them set to the system "headline" or "body" options for all size classes, but that may be a separate issue.
Any help is greatly appreciated!
App written in Swift, using storyboards for iOS8, btw.
Edit:
The more I look at this, the more I'm convinced it's not related to the bars, but the entire app - the fonts and everything. The whole app appears to be zoomed in to 120%, which is subtle, but looks really bad and wastes space.
I have also now seen this in a second app - the Apple DateCell sample. It also appears 'zoomed in' when run on the iPhone 6 simulator.
Edit 2:
This effect is even more exaggerated on the iPhone 6 Plus simulator - everything is even more 'zoomed in' looking - the top and bottom bars are almost twice the height they should be. This can be seen by downloading the Apple DateCell sample and running it.
Edit 3:
ARGGGG, all this time wasted, and it was due to the launch screen image - why on earth would a launch screen image not being set cause the entire app to scale?
I finally figured this out - it was related to the launch screen image. Apparently if it's not setup right, the whole app scales on the iPhone 6 and 6 Plus for some reason. This question is what pointed me to the answer.
For me, I had to both create a LaunchScreen image in Assets, and set it in the project file, and ALSO select the launchScreen.xib as the Launch Screen File in the project. I don't have a real launch screen yet, so these are both just empty or defaults in my case.

Resources