Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add image to uitableview cell

I have a tableview, how can I add image to the left of this cells?

like image 420
AMH Avatar asked May 03 '11 12:05

AMH


People also ask

How do I add images to UIImageView?

With Interface Builder it's pretty easy to add and configure a UIImageView. The first step is to drag the UIImageView onto your view. Then open the UIImageView properties pane and select the image asset (assuming you have some images in your project).

How can we use a reusable cell in UITableView?

For performance reasons, a table view's data source should generally reuse UITableViewCell objects when it assigns cells to rows in its tableView(_:cellForRowAt:) method. A table view maintains a queue or list of UITableViewCell objects that the data source has marked for reuse.


1 Answers

cell.imageView.image = [UIImage imageNamed:@"image.png"]; 

UPDATE: Like Steven Fisher said, this should only work for cells with style UITableViewCellStyleDefault which is the default style. For other styles, you'd need to add a UIImageView to the cell's contentView.

like image 150
André Morujão Avatar answered Oct 18 '22 23:10

André Morujão