Subscribe ( )

iPhone Programming Tutorials


 

Forum

You must be logged in to post Login Register

Search 

Displaying Images in TableViewCells

User Post

4:56 am
April 14, 2009


ned1972

Noob

posts 1

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?


Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

3 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 934 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.