Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell with image on the right?

Is there a way to set the UITableViewCell.image to display on the right hand side of the cell instead of the left? Or will I need to add a separate UIImageView on the right side of the cell layout?

like image 740
Oliver GL Avatar asked Apr 23 '09 05:04

Oliver GL


2 Answers

No. But you can easily add an image view as the accessory view to a table cell for the same effect.

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"foo.png"]]; cell.accessoryView = imageView; [imageView release]; 
like image 149
Alex Wayne Avatar answered Sep 24 '22 16:09

Alex Wayne


For simple cases you can do this:

cell.contentView.transform = CGAffineTransformMakeScale(-1,1); cell.imageView.transform = CGAffineTransformMakeScale(-1,1); cell.textLabel.transform = CGAffineTransformMakeScale(-1,1); cell.textLabel.textAlignment = NSTextAlignmentRight; // optional 

This will flip (mirror) the content view placing any imageView on the right. Note that you have to flip the imageView and any text labels also otherwise they themselves would be mirrored! This solution preserves the accessory view on the right.

like image 20
TomSwift Avatar answered Sep 21 '22 16:09

TomSwift