Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJeanne Merle
3,390 PointsNo image displayed
Hi, My program is running, but no image is displayed in the Image View. The container is just orange, with nothing in it. I have added a property "iconFile" if Playlist struct, that contains the name of the file ("coffee.pdf" in our case) ... var iconFile : String ... let iconName = playListDictionary["icon"] as String! self.iconFile = iconName ... and i use a println in the viewDidLoad method to see if the dictionary is ok, which seems to be the case. ... let playList = PlayList(index: 0) playlistImageView0.image = playList.icon println(playList.iconFile) ... "coffee.pdf" appears in the debugger, at the bottom left. But the image "coffee.pdf" does not appear in the View.
Can you tell me why ? Thanks ! I really would like to fix this before going further.
3 Answers
Jeanne Merle
3,390 PointsOk I have looked in the Internet and found the solution here : http://stackoverflow.com/questions/24049537/defining-the-file-a-uiimage-will-use-swift
the right parameter to create an Image with a file name is : UIImage(named: String) rather than UIImage(contentsOfFile: String)
and now it works !
thanks for your concern Greg, see U
Greg Kaleka
39,021 PointsHi Jeanne,
I think you might want coffee.png, rather than coffee.pdf.
Let me know if that works!
-Greg
Jeanne Merle
3,390 PointsHi Greg, I'll try at home this evening, but I've pasted the exact same code as Pasan (in the "Teacher's notes" section), and it's "coffee.pdf". ++
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsAh cool - thanks for updating us! For future reference, it's very helpful to actually see your code. Check out "Tips for asking questions" in the right sidebar ->