Alex Rivera | Logout

Programmatically Add Image to TableView Cell

Asked 2011-08-24T17:17:41.560
23

I have a UITableView that gets information from a server and publishes the data into a table view. Inside of each cell is the information from the server.

For the purpose of this example, let's say the information we get from the server are numbers: 1, 2, 3, 4.

What I want to do is add an image (programmatically because there are if statements involved, etc) to the left side of the cell, and the text (1, 2, etc) right next to it.

Basically, I want each cell to look like this:

 _____________________________________
| (IMAGE) (TEXT)                      | --CELL 0
--------------------------------------
 _____________________________________
| (IMAGE) 2                           | --CELL 1
--------------------------------------

Please excuse my crude illustration. :)

Edit
Report

1 Answer

4

UITableViewCell objects have an imageView property; you can just set this image view's image and it will automatically display the image in the right place with the title next to it.

answered 2011-08-24T17:22:44.360

Your Answer