Subscribe ( )

iPhone Programming Tutorials



If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

You must be logged in to post Login Register


Displaying Images in TableViewCells

User Post

4:56 am
April 14, 2009



posts 1


Good morning,

 I have a set of images that I have imported into my project.  I am trying to set the image in each cell to one of these images.  For instance, I construct an NSString listing the image name such as NSString *filename = [NSString stringWithFormat@"%@-small.png",key]; where key is an index of an array, so the images are named 1-small.png, 2-small.png, etc.

In the method tableView:cellForRowAtIndexPath: I am grabbing the row from the tableView, getting the number and creating an image filename.  I have verified this using NSLog that the filenames are being created correctly.  I then go through the motions of checking the cell dequeue and if it is nil I create a new cell, assign it the image along with the text of the key (1, 2, 3, etc).  However, only the first cell in the table gets an image.  All of the rest are just the text. 

I am using UIImage *image = [UIImage imageNamed:imageName];

cell.image = image;

cell.text = key;

return cell;

Each cell gets the correct text but no images.

Any ideas?

About the iCodeBlog forum

Currently Online:

2 Guests

Maximum Online: 25


Groups: 2

Forums: 6

Topics: 310

Posts: 749


There are 662 members

There are 1 guests

Brandon has made 87 posts

Top Posters:

bobcubsfan - 53

crazyiez - 30

VertigoSol - 26

AdeC - 17

Uhu - 17

Administrator: Brandon | Moderators: VertigoSol

© - Version 3.1.4 (Build 357)