Image not showing in UIImageView in Interface Buil

2019-02-11 12:30发布

I have a UIView with an UIImageView dragged onto the view. All of a sudden, for all my xibs, the image no longer shows up. There is a blue X. However, when it builds, the image is there.

At one point, I deleted and regenerated all my images and moved some into a subfolder in Xcode. Normally, when you go to select an image for an UIImageView, IB allows you to pick from any image in the project. But, I can't see any of the images I had put in the folder anymore in the dropdown.

All I see in the dropdown on the Inspector is the one image I want, but that is also the one that is not showing up. And like I said, if I build it on the device or simulator, it all works.

There is some cache or something screwed up somewhere. Everything builds with no errors. I cleared the caches and rebuilt. It all works. No error or warnings. But...I can't see any other images and IB still thinks it's missing the image that is clearly selected in the dropdown.

So how do I get Xcode and IB back on track and see what assets it properly should be seeing in the XIBs?

18条回答
虎瘦雄心在
2楼-- · 2019-02-11 12:48

The .png was missing from the end of my image name in attributes inspector

After cleaning, re-importing and checking the assets where mapped correctly, nothing worked, though I found my image (which is a png) showed up once I entered .png at the end of the image name in the attributes panel.

enter image description here

查看更多
对你真心纯属浪费
3楼-- · 2019-02-11 12:50

My recipé: CLEAN + Build + QUIT XCODE AND THEN REOPEN IT!

Voilá!! It's there!

查看更多
时光不老,我们不散
4楼-- · 2019-02-11 12:55

Just ran into this issue. Exported the identical images in Adobe Illustrator. One as transparent, the other as white. The transparent one showed up with a big blue question mark. Running it, worked fine however. Something to do with IB and transparent PNGs

查看更多
够拽才男人
5楼-- · 2019-02-11 12:55

For me it was because the images had a ".png" in attributes inspector. Removing it fixed the issue

查看更多
聊天终结者
6楼-- · 2019-02-11 12:56

In my case when I have created new project in Xcode 6 I can not show the images in the Simulator and as well as in device. I have imported all the images in the image assets making a folder within that.Now I have imported all the images, all are working fine now. All images are now showing now.

Follow these steps:

STEP 1:

Step 1:

STEP 2:

Step 2

STEP 3:

Step 3

and then Import images which you need. Reference Link: StackOverflow link

查看更多
神经病院院长
7楼-- · 2019-02-11 12:57

Make sure you're referencing an image asset that actually exists. I had added my files to the Xcode Asset Catalog (.xcassets) as usual, but forgot to rename from the default name of "Image" to the name I was using in the storyboard.

查看更多
登录 后发表回答