문제

all images in my storyboard are now ? images. This happened after I imported all media assets into a new .xcassets structure. The app runs fine and the images show when the app runs, but what can I do to restore them in the storyboard?

도움이 되었습니까?

해결책

Remove the .png extension from the image names in the storyboard. Xcode5 now uses the image name, not the filename.

다른 팁

Try first to do a clean build. In a project including git repo I was facing this problem. It solved each time by just by clean building the folder:

⇧⌘K
or
Product-> Clean build folder

It's likely that the accepted answer will solve the problem. However, in the event that you're still scratching your head:

If you have a naming convention for assets that involves "." characters (for example, "icon.menu.normal.png"), you will find that XCode and IB will very happily cooperate before using .xcassets. If you then shift everything into .xcassets, you will find that all of a sudden:

  • IB will show the images correctly provided you leave off the file extension. However, when the app runs, none of IB's correctly visible images will load;
  • If you include the file extension in IB, IB will display them as broken question marks but they will display correctly in the app.
  • If you use imageNamed: you find you need to include the file extension for assets, otherwise northing happens.

The solution? Don't use "." in your asset naming conventions (bad programmer). Using underscores ("_") works fine too, is just as legible and saves you a lot of hassle.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top