First create a UITableViewCell template with IB, put there a fixed lenght UILabel followed by a UIImageView. No problems, their values are easy to setup at cellForRowAtIndexPath with view tag id numbers:
UILabel *label = nil;But how to "float" that image right after text string? UILabel is fixed sized, so that won't help. Have to check the size of label.text instead:
UIImageView *image = nil;
CGRect frame;
// Title
label = (UILabel *)[cell viewWithTag:1];
label.text = @"Title text";
// IconThat's it, very simple! Just beware that your tag numbers MUST be unique.
image = (UIImageView *)[cell viewWithTag:10];
image.image = [UIImage imageNamed:@"logo.png"];
// Icon positioning
frame = image.frame;
CGSize f = [label sizeThatFits:label.frame.size];
frame.origin.x = label.frame.origin.x + f.width + 4;
image.frame = frame;
I had a problem that Interface Builder wanted to set UITableViewCell tag same as my image tag. No errors, no warnings, no indications of problem - except that I couldn't get my image frame no matter how much I banged head into brickwall! Removing tag didn't help, it just automagically came back. Ouch!