image is not rendered though its shown in the storyboard - ios

So I'm working on Xamarin studio 6.1.1 and am building a native Xamarin.iOS app, on the LaunchScreen.storyboard file I have two UIImageViews, assigned image for each one from image assets.
the problem is when I run my app one of the two images is shown and another one is not though both are shown in the storyboard file.
I have placed all my images directly in the Resource folder and made sure that there is nothing missing, The scenario is soo simple and I'm not sure what the reason behind this.

Related

Images not displaying from Assets

I have a xamarin.ios (Using VS mac) project that I'm trying to add images to. I have 5 images and only two of the are loading. I have followed https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/images-icons/displaying-an-image?tabs=macos for uploading images. It's weird cause the two images that are loading don't show up in the Assets folder when I open it up in Xcode but they do appear in finder. I'm not sure why I cant get the other three to appear..
"Coke" and "blt" are the only ones that show in the app, but they don't appear in the Assets in xcode.
I've made sure spelling and extension usage is all correct.
Any help would be great.

Images with #1x #2x suffix do not appear in app

I am struggling with an issue in an app with a couple of custom images in the navigation bar. This was all working perfectly well until yesterday, when the images stopped appearing in the navigation bar.
There is a clue that, when I add one of the images to a view controller via the xib editor, I get a warning message e.g. Could not load the "back-arrow.png" image referenced from a nib in the bundle with identifier "com.test.myapp"
What does work is renaming the files from e.g. back-arrow#2x.png to back-arrow.png - but then its displayed at the wrong size. I managed to get one of the images working and displaying correctly yesterday, but in trying to get another image to display it has disappeared again.
I have checked the files are present in Copy Bundle Resources. They appear in the Xcode image browser.
EDIT:
When I delete the #1x images, the icons appear again. What might be going on here?
Using Xcode 8.1, testing both in simulator (iOS 10) and iPad 2 (iOS 9).
The images were not in the .xcassets folder, just added as Resources. I did it the proper way and made each image into an Imageset, and it now works as intended.

Launch Screen storyboard not displaying image

I'm trying to get an image to display as the launch screen from my Launch Screen.storyboard file, however the image never displays. I have labels that show up fine, but the image doesn't appear.
This is how the launch screen looks in the Launch Screen.storyboard file:
However when I run the app on the simulator (as well as on the physical device) this is what shows up:
As you can see, the label "Test" shows up fine, however the image does not display. I'm really not sure why this is happening and nothing I try seems to work. If anyone has any ideas of how to fix this it would be greatly appreciated.
After restarting Xcode, cleaning the build and a number of the other suggestions on SO about this problem. What actually fixed it for me was a hard reboot of the device. (I wasted over an hour on this)
I suppose it just goes to show that the old saying have you turned it off and on again is still true for the latest gadgets!
How to reboot iPhone XS or iPhone XS Max
Quickly press and release the Volume Up button
Quickly press and release the Volume Down button
Press and hold the Side Button until the Apple logo appears
I was messing around with this for hours too. But i found the solution now. You need to add the image to your project and also to the assets.xcassets via drag and drop.
Had the same issue, adding the image to the "Build Phases -> Copy Bundle Resources" fixed it for me.
Follow below steps,
Remove application from the device
Restart device
Build again
If not working, delete derived data. Xcode Preference->Locationtab->Derived data. Then do follow above steps.
Very frustrating. Solution that finally worked:
Do hard reboot of device
Delete app
Install app from Xcode
It happened to me and makes me crazy, beyond get me lose some minutes 'til I figure it out.
So, like was said before:
Import the desired image to your Xcode project (just drag and drop it)
Change its Constraints and Alignment
Update frames resolving Auto Layout issues
In the Attributes inspector tab menu (generally in right corner menu xCode), on Image view > Image, remove image extension (.png or .jpg) - that's the trick
On the design screen, it will not appear, but when you run your app, it will be shown.
I hope it can help!
At last, restart the phone works for me!!
I have spent hours on this issue. Had tried change the images name, delete the whole image assets, modify info.plist, restart Xcode and even tried to set all the attributes of the images(which you can tell how desperate I was).
After invested a lot of time, I got the solution:-
Step 1:- Quit Xcode
Step 2:- Delete the app from device/simulator
Step 3:- Restart your device (if you are using simulator then you have to quit simulator)
Step 4:- Clear all derived data
Step 5:- Clear Bin
Step 6:- Open Xcode and relaunch the app, it will work
I faced the same problem.
Add an new imageset to XcodeAssets.
Add images to to the imageset.
Add image view to launch screen and set your imageset as image
On Imageview's attributes inspector, uncheck 'clears graphics context'
Clean the build folder and run again.
This issue is related to the Assets.xcassets to fix it you must add the image as resource but not in the xcassets folder and then should work just fine
In my case, resetting content and settings for simulator fixed the problem.
After trying everything on several StackOverflow threads, here's what worked for me:
Use a .png
Do not include it in your Assets catalog. Add it to your project's hierarchy directly, as you would add any source file.
In the image view, load the image including its extension. Example: launch_app_image.png
(Might have to clean product or derived data to update, but I didn't have to)
It seems there is some problem with resource caching in xCode. Had the same problem, restarted xCode and everything works fine after that.
Restart your device and clear x-code derived data
I had that problem after adding image to project and shotdown the device the problem solved
Was changing the background image of the splash screen and the new image wasn't showing (react native project).
Following the answers from others.
I did all the below and it was fixed:
Clean build.
Remove app from simulator
Quit simulator
Restart XCode
Run app again
Well As of now there is retina device available and I ignored #1x image in Assets.xcassets.
In my case, I have app logo in Splash screen which is not visible when I run the application.
After wasting so much time I figured out that I only provided #2x and #3x images for that logo image.
This issue is resolved by adding #1x version of that image.
In my particular case, the splash screen worked for the simulator and other devices, but stopped working for one specific device. This lead me to believe that it was some caching data kept by xcode (v10 and iPhone 7 v12.1).
I deleted the derived data at: ~/Library/Developer/Xcode/DerivedData/ only emptying the folder contents, not deleting the folder. I then rebooted the mac and the iPhone and cleaned and rebuilt the project, and now it is showing up.
I'm not sure if all of this was necessary, but didn't want to waste any more time narrowing it down, so the above sledgehammer approach worked for me. But of course it always depends on your specific situation - mine was device specific; for others it could be the actual image or launch screen layout etc.
Actually, for some heavyweight images, it isn't a good situation to add them into images.xcassets, because the app loads images.xcassets lightweight images before launch. So I put splash screen images at the first root of load and then the issue has gone:
Create a new Group in the root of the project
Drag and drop your image inside of the yellow group folder
Rename it to a different special name
Back to your xib (or storyboard) file and address the ImageView to the special name that it is in step 3.
Clean and build again, then you can see your image.
Hint: You can create your ImageSet in the images.xcassets but place them in the root of the project.
Importing images as regular files worked for me. Don't add image from assets catalog!
You have to make sure that the file name of your image has a format like .png or .jpg at the end otherwise it will not work. Also, before adding your image, you have to make sure that the image file is in your "Assets.xcassets" folder within your project. This can be done with a simple drag and drop. Also, make sure when you've added your image to your storyboard that the image name in the top left also matches the real image file name. I would try looking into Constraints too. Hope this helps. Good luck with your App.
I tried so many things with this (this thread alone seems to have a million ideas and half of them are conflicting). The problem for me was that when I did things like restarting the device and Xcode, it would cause the image to show for a few sessions of the app, and then it would stop (I have no idea why, but WOW it was annoying).
After countless hours, I found that A.G.'s answer in this thread is the correct one. The one thing I was doing wrong was that I was creating a new image set within xcassets, but I was then still using the name of the image within the UIImageView inside of the storyboard instead of using the name of the image set.
To clarify, what you would do is create a new image set and name it something like "Launch-Defaults", and then add your images to it. Then, within the UIImageView inside of the storyboard, you use the image "Launch-Default" (not including an extension since there is none since this is an image set).
When you do all of that, the image should actually appear correctly inside of your storyboard. Some people say the image will display blank if you don't use the extension (.jpg or .png), but I assume that is because they are not using the name of the image set. Others say you need to use an extension like .png or .jpg, but the key is to create the image set inside of xcassets and then use that image set inside of the storyboard. When done correctly, there should be no funkiness like an image not showing up or the Launch Screen only working some of the time (requiring a reboot).
Just to add my $0.02 to this question; I got this solved by using PNG images instead of JPG/JPEG images.
After converting the images to PNG and crunching them to reduce the size a little, everything worked fine.
My issue.
Reason: I have renamed the images after dragging into Xcode.
Solution: Don't rename images after dragging into Xcode. It creates problems for understanding Xcode. Rename images before dragging/adding into Xcode.
Hope it helps you out!
I spent hours on this problem before finally realizing my mistake. When you add an image to a UIImageView, it will use just the name of the image. If your images are in a different folder than your storyboard, they will show up in xcode but not when running the app. You must add the appropriate file path prefix, for example, images/image.png. It will now appear as a blue question mark in xcode, but it will work in the app.
I faced the same issue. Tried different solutions for that but nothing proved to be helpful. I then realised that the image was not visible only when i directly installed the app into device and the app is still connected to the xcode. If i disconnect it and then open the app the image was visible as expected.
It might be a xcode bug.
I tried cleaning the project, removing the png, removing the constraints did not work for me.
I just made one more copy of the image and renamed the copy then deleted the old image and added the new image (Same, with name changed) i just gave that image and it worked for me.
Also i am not using the Assets.xcassets, using the image in a folder.
My first mistake was, that I created a normal .storyboard, renamed it and defined it as launchscreen in the project settings. I this case I had image problems. It seems that some settings are missing in this case then, so I just created a new file via file->new and picked directly the "Launch Screen" and then it worked.
Also I had in mind that, that layout constraints are not supported in the launchscreen for some reason. Maybe it was like that in the beginning, not sure, but now constraints should work.
Maybe this helps anyone.
In my case, it was a bit more than just rebooting the device.
My launch image was stored in other Assets (Other Pods).
Had to move the image to App project's Assets.
And then rebooted my device. (Check simulator first, it should work).
Then it worked.
Images can be in format png/pdf, single scale or not doesn't matter.
I was stucked into same issue thanks to the below reference I am able to resolve the issue
https://developer.apple.com/forums/thread/19759?answerId=75438022#75438022
Though it is not necessary to change the image name and removing the extension while selecting the image for imageview, I simply created one folder named resources and added my image inside that folder coz I thought it would be not good to put images directly into the root folder
Hope this would help.
Happy Debugging!

Modify launch screen storyboard

i've added a launch screen storyboard in my project. The storyboard contains a UIView with a UIImageView. The UIImageView shows a .png that i download from a server, and this image could be different every day.
I noticed that iOS cache the images created from the storyboard, but when i start the app with a different image, it shows the older one, and not the one i've downloaded.
The solution should be to change the storyboard to tell the OS that the splash is changed and it could generate new images.
But i don't able to tell the OS the storyboard is changed and it show always the same image.
I've tried to change the structure of the view controller adding some views.
The launch screen interface is supposed to be static, it is loaded before your code starts running. So there should be no way to dynamically change the images there.
Maybe someone will find an obscure solution for that, but my guess is that it's not possible right now.
Your project should contain a launch screen .xib file when you create it. You can simply edit the .xib to your liking. There's no need for a new/separate storyboard file.

Xcode not finding images from atlas folders when running

I have an app created in Xcode which has loads of images. To make it slimmer i created folders within Xcode as .atlas and made sure that these contained the (*.png) images i wanted.
from the storyboard and XCode navigator i can see the png files, and the UIImageView objects show the correct image selected from the dropdown.
so there is no problem with the images being accessed, and no issue with file name.
When i clean/build/run the app through the iPhone simulator no images show the outcome is blank...
There are a bunch of different reasons why this could be the case.
Here are a lot of answers that worked for some.
http://solvedstack.com/questions/could-not-load-the-image-referenced-from-a-nib-in-the-bundle-running-on-device
In my case i had the same setup you described.
One Texture Atlas and i wanted to use some of the pictures in there in an UIImageView.
I assume since TextureAtlas is mostly meant for SpriteKit, i added my Pictures that i wanted to use to the Images.xcassets folder.
Then the preview in the Storyboard works as well as on the device.

Resources