Why image not shown in simulator when using XIB designable? - swift

Currently i'm trying to change icon image from designables image
I have main project with bundle com.abc.def (firstbundle)
I put the image on another bundle com.abc.ghi (another framework connected to main project)
When i set the image on viewcontroller (in the first bundle), the image shown in the interface builder. (2nd image)
But when i run it on simulator, the image is not shown. And there is error in console
Could not load the "hide" image referenced from a nib in the bundle with identifier com.abc.def -> This error means, xcode try to find image from first bundle not from second bundle. How to make it also check image from second bundle ?
The problem is only if i using designable option from XIB. If i'm not using it, just define directly inside source code "remove #IBInspectable from the 1st image" (from another bundle). The image shown correctly

Related

Could not load the "block" image referenced from a nib in the bundle with identifier - can't access image in other bundle

I got error Could not load the "block" image referenced from a nib in the bundle with identifier while trying to set image from from .xib file in one module, which (image) reside in another module. I'm trying to set image for a UIButton (not an UIImageView)
I've seen this iOS: How to use images in custom bundle in Interface Builder?
Article but it wasn't helpful.
I've tried
MyBundleName.bundle/iconName
MyBundleName/iconName
MyBundleName.bundle/Resources/Assets/Images.xcassets/iconName
I putted that in .xib GUI (when you suppose to set image for UIButton) but didn't succeed
In fact, in preview (.xib file in XCode) everything is nice, but after i visit the screen it doesn't work (and i see error i specify in article name in console)

Launch Screen Localized Image not rendering

Problem: The Launch Screen Image is either not rendering (white space where UIImage should be), or not being localized.
My project is set up to load the LaunchScreen from Launch.storyboard via the target's General configuration.
Some facts:
XCode 7.3
Multiple Targets with unique Launch.storyboards.
Tried with two images one was a localized Image.png file (in resources, not in .xcassets), the other was 2 unique image sets in
.xcassets one named "image_en" the other "image_fr".
Some things I tried:
Cleaning the project, resetting the simulator, restarting xcode,
deleting the app's DerivedData.
Created a new Master-Detail project and localized the LaunchScreen.storyboard file. Then added
image_en in en.lproj/LaunchScreen.storyboard and replaced the image
in the fr.lproj/LaunchScreen.storyboard with image_fr .xcassets files
this solved the image not loading problem, but the image was still
not localized.
Created a new Master-Detail project and localized the LaunchScreen.storyboard file. Then I localized the Image.png and added it to the LaunchScreen. This image appeared, but wasn't localized.
Question: Why is a black void appearing in the Launch Screen localized Image.png in my original project? && is this an xcode bug or am I doing something wrong?

Could not load the "" image referenced from a nib

I have no images called "" (nothing). I've gone through the .xib file of the screen where this pops up and can't find anything that would cause this. Anybody who have had the same issue? Here is the full warning:
Could not load the "" image referenced from a nib in the bundle with
identifier "com.blah.Blah"
You can do this to check it from your storyboard, or nib.
Open it as Source Code:
Then "Find" the image name in it, see if it exists but already invalid in your project, probably you have deleted or changed its name, and now it doesn't seem valid.
I had the same issue and in my case there was an UIButton with an invalid image reference in the storyboard file. The reference wasn't empty so it was not trivial to spot by just searching for "" in the storyboard file. However, Xcode did show "Unknown image" for the button in the Background field instead of "Default Background Image". In the storyboard file it appeared as
<state key="normal" title="Use" backgroundImage="0E39AEA8-7F29-40B2-96B1-63B99047E8D5">
so perhaps grepping for backgroundImage and looking for non-familiar references will help find the cause.
I had this warning because of a UITabBarItem. In the attributes inspector for the field "Selected Image" I had a file listed that was also the value for the field "Image". Nevertheless, I received warnings until I made the "Selected Image" field blank.
Just for reference, this problem is also caused by using .jpg images and referencing them inside of storyboards/nibs. iOS 8 appears to be able to handle the proper type checking between jpg and png images at runtime. However, on iOS 7 and below you will need to manually set the image in the code and remove the image reference inside of the storyboard to get rid of the warning.
Remember you need to manually set the .jpg when referencing jpg images.
[self.imageView setImage:[UIImage imageNamed:#"yourImage.jpg"]];
I came looking for the answer. I searched my entire project and storyboard source code for "" and nowhere could I find it. The clue that the view that is displayed when the error appears is the one you need.
Open your xib or storyboard selecting the relevant viewController.
On the left click all grey arrows to expand the selection in your
view
look for the UIImageView icon (its the one with the palm tree)
select it and open the "Attributes inspector" on the right hand side.
In the ImageView section at the top in either or both Image and
Highlighted you will see greyed out "unknown image".
Use the drop down menu to change this from "unknown image" and build
run
voila
The nib (or ultimately the xib) that is the cause of the warning message is the one that is loaded when the message gets written. You then can look at the controls that use images in the inspector and find one where the image name is "Unknown image". You can then clear this value by setting it to some value and then clearing out the value. Note that with UIButton you'll need to try the four different values of "State Config" (Default, Highlighted, Selected & Disabled) to see where the invalid reference might be hiding.
In my case it was Unknown image in UIBarButtonItem in storyboard.
Very simple remove the image that is not displaying from you project and then clean the project by going to Product--> clean then once again put the image into your project and done. this worked for me.
In xcode 5.1 I had this same issue. The only way I could finally get it to work when using storyboard was to add the images as an image asset catalog. From what I read maybe they changed something in 5.1. I thought that storyboards don't have nibs - so it would make sense that asset catalog replaces the old method.
Project > General > App Icon Arrow > Import New Folder.
As soon as I did that the NIB references went away and my images showed up.
I'm using Asset Catalog on Xcode 6. Simply removing and re-adding the Asset Catalog fix the problem
in my situation, in my xib file,I had ever setup image name for some UIButton and UIImageView ,and delete these image name after sometime, but for unknown reason, these image still apear in the Interface Builder Editer, finally I reset these image name with any image name and delete them again,now problem resolved.
This worked for me:
1- Quit Xcode
2- Make a copy of your .storyboard for backup.
3- Open your .storyboard in a text editor and delete image nodes and image node attributes with empty references.
delete node like this --> <image name=" " .../>
delete image attributes like this --> <tabBarItem key="tabBarItem" title="untitled" image=" " id="6"/>
4- Save the file
5- Open your project again in Xcode.
6- Run Product->Clean
7- Run your project
Warning should be gone.
I had a very similiar problem which I eventually found. The line below was causing the problem using the open as source code method mentioned above.
<tabBarItem key="tabBarItem" title="Events"
image="319365D1-7058-46CD-8420-18E0EAFB2F29" id="a5a-IF-j9f"/>
I got this error from an undo action, simply dropping the image back onto the view controller solved the problem.
Atb
In my case it was because one of my button images was wrongly added to the Background Image container instead of the Image container (in the Inspector). I found it by going through the entire storyboard hierarchy and checking each image and button setting.
Please do a search for image= shows various results. Select results from nibs or storyboard open it, if there is some value like image="2342D4DF-1E6B-42B8-847A-F9F622921D02" delete it and enjoy.
i also faced same problem because i edited image in photoshop and saved as a psd format make sure you save your edited images in jpg or png format in my case that was the problem hope it helps!!!
I got this problem for all of my images after switching one of the label's text to 'attributed' and using one of the 'Fun' fonts. Even though I switch it back to 'plain' I still get the "Could not load..." error - until I re-load and re-reference all of my images again.
Initially my image name is "bg" When i found issue, i rename image as "background" but when click on image and hit "Show in Finder"changes was not reflected. image was name as "bg-1.jpg".
so i removed from project convert image to png and drag and drop into
project it works for me.
Believe or not, sometimes this happens because some IBOutlet was removed and in the storyboard have the reference to it.
Make sure the 'Target Membership' for the 'Assets.xcassets' has been selected.
Click 'Assets.xcassets'
In the 'File inspector', make sure 'Target Membership' selected.

iOS: How to use images in custom bundle in Interface Builder?

I have a bundle where i put images in it.
The contents are:
MyBundle.bundle/images/picture1.png
MyBundle.bundle/images/picture2.png
I dragged MyBundle.bundle into my project.
Now I can see these images in Interface Builder and can even use them. However, when I run the app, I don't see the images.
What's wrong?
Thanks,
Make sure the bundle is getting copied over in the "Build Phases" of the project settings for the target.
Also, try setting them progrmatically and see if they show:
myImageView.image = [UIImage imageNamed:#"MyBundle.bundle/images/picture1.png"];
I just tried this in my project and found that what you need to do is specify the image with the bundle name in front like this:
In the IB the image will look broken:
but when you build and run your project the image will show correctly.
So, in your case, use MyBundle.bundle/images/picture1.png in the actual Interface Builder Image box.
Also, when you dont put the bundle name in front, you get this warning when you load the view with the bundle image:
2011-10-12 08:22:16.360 UTDebug[721:11c03] Could not load the "map.png" image referenced from a nib in the bundle with identifier "com.companyname.myproject"
You need to put the XIB in the bundle, too. When you do that, resources for the interface will be relative to the bundle, so they'll work both in IB and when you load the interface in your app.
You might have a stray build setting from having created the bundle as a Mac OS X target.
See my other answer for the solution.

Images in Interface Builder when using MonoTouch

I'm new to MonoTouch and iPhone development. I have my images (PNG) in a resources folder in MonoDevelop, however if I want to set the image property for a button in Interface Builder, how do I do that? It's always a blank dropdown. Do I need to use XCode to access the XIB file and then somehow embed the button image file I'll need in it?
This is a known limitation of MonoDevelop and Interface Builder. To add images to an XIB in Interface Builder they must be part of an XCode project, which of course coming from MonoDevelop they're not.
To achieve what you're trying to do you will need to set the image via code, and ensure the build action of your image is set to Content. To do this, simply right click your image inside MonoDevelop, and select Build Action > Content.
On your view with the button on it, create an outlet in Interface Builder for your button, hook it up, then from code to set your image, you just need to use the .FromFile("path/name") method of UIImage.
UIImage buttonImage = UIImage.FromFile ("resources/image.png");
myButton.SetBackgroundImage (buttonImage,UIControlState.Normal);
That's off the top of my head, but I think that should do it.
You can manually set the image in Interface Builder, but it wont show up until run time. The image name can include a path, e.g. "images/settings.png".
All solutions given here are completely wrong and misleading. All you need to do, is place your images in the Resources folder (on the project root), and add your images to this folder. After adding files to this folder, mark all files and make sure their build action is set to BundleResource.
I also needed this to work, here is a workaround I found.
You need to create a dummy xcode project. Place it in the same folder as your project.
Add all your xib files and image files to that xcode project by dragging them in when the project is opened in xcode. Now you will be able to see the preview of the images.
The image files must be in the same folder as the project file and xcode must be opened with the dummy project while the interface builder is opened.
Not great - but solves the issue for now.
Here is a sample project I have created.
For this issue to be resolved on the MonoDevelop side - some inter-process communication code needs to be created, I think that a good starting point will be looking for "PBXProjectWatcherServerConnection-3.1.2" in google.