1

I'm following along with Paul Hegarty on iTunesU and he adds jpegs to his project by selecting a group in finder and dropping them into the view associated with Images.xcassets. In my project that view has white icons called AppIcon and LaunchIcon. In the tutorial the jpegs are dropped and added, then a simple [UIImage imageNamed: ... can load them into the running program. But when I try to drop images onto the area, nothing happens.

I tried adding them to the project tree view on the left, and they were accepted there, but didn't get [UIImage imageNamed: to work.

Any idea what is wrong here?

TIA Mark

MarkAurelius
  • 1,203
  • 1
  • 14
  • 27
  • 2
    possible duplicate of [How can I add JPEGs to an asset catalog in Xcode?](http://stackoverflow.com/questions/18785946/how-can-i-add-jpegs-to-an-asset-catalog-in-xcode) – Vladimir Feb 27 '14 at 11:09
  • Thanks, Vladimir. It seems that it only accepts PNG files. I converted one to PNG in preview and Images.xcassets accepted that. – MarkAurelius Feb 27 '14 at 11:37

2 Answers2

2

There is no where such written that we have to use only png for assets catalog, but only I have seen at Create and Set iOS Launch Images they are saying for png, why don't you convert your jpg to png and give a shot.

Saurav
  • 179
  • 2
  • Yes, that seems to be what is needed. I found that out just as you were writing your answer. – MarkAurelius Feb 27 '14 at 11:39
  • Fortunately, Preview will allow you to open all the jpegs at one time and export them all at once as PNG files. – MarkAurelius Feb 27 '14 at 11:50
  • You should be able to use automator to convert a folder of jpgs to pngs. – Fogmeister Feb 27 '14 at 13:05
  • I have a valid looking set of files for the app (It's the tutorial from iTunes where you have images for face cards). But I'm now getting nil when I do UIImage imageNamed. I have tried a number of things on the web, including cleaning, deleting the app, reexporting the image from Gimp, to no avail. – MarkAurelius Mar 02 '14 at 03:48
  • AH, I have now solved that little problem: The filenames include the playing card suit symbols, and it seems there are 2 different versions of them. I had on version in the files and assets, and another in the code. – MarkAurelius Mar 03 '14 at 06:08
  • iOS 8 supports JPG in xcassets. But for non-photographic UI elements, you should use PNG. – Zev Eisenberg Aug 13 '14 at 15:21
0

Had to drag and drop it into the folder in xcode. Doing it within vscode project didn't work.