UIImage in UITableviewcell layout

I have a problem layout the objects in the code. Here is a picture of current and desired status:

And here is the code

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];    
if (self) {
    self.title = NSLocalizedString(@"My Favorites", @"My Favorites");
    self.tabBarItem.image = [UIImage imageNamed:@"second"];

}    

favoritesTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 364) style:UITableViewStylePlain];
[favoritesTable setHidden:NO];
[favoritesTable setDelegate:self];
[favoritesTable setDataSource:self];

[self.view addSubview:favoritesTable];        

[favoritesTable release];

return self;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"<#MyCell#>";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}

NSInteger objectLocation = indexPath.row;

FoodData* food = (FoodData*)[resultsArray objectAtIndex:objectLocation];    

cell.imageView.image = [UIImage imageNamed:@"paris.jpg"];
cell.imageView.frame = CGRectMake(270, 4, 40, 36);    

cell.imageView.userInteractionEnabled = YES;
cell.imageView.tag = indexPath.row;

UILabel* lblText = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 260, 20)];
UILabel* lblType = [[UILabel alloc] initWithFrame:CGRectMake(0, 21, 260, 20)];

[lblText setFont:[UIFont fontWithName:@"Helvetica" size:10.0]];
[lblType setFont:[UIFont fontWithName:@"Helvetica" size:9.0]];

lblType.textColor = [UIColor blueColor  ];

[lblText setText:[food foodName]];
[lblType setText:[food foodType]];

[cell addSubview:lblText];
[cell addSubview:lblType];

[lblText release];
[lblType release];

return cell;
}

Answers


on ios5, making use of the prototype cell on the IB will be the easiest way out for you.

if you are not on ios 5, i do highly recommending using a custom tableviewcell.

The short solution to your issue can be found here in the link below.

UITableViewCell with image on the right?


Need Your Help

wcf configuration questions

c# asp.net wcf

I'm still new to WCF and had a few questions on why certain sections are needed, if they are, in WCF:

iOS jailbreak development without device

iphone ios ios6 jailbreak

Is it possible to develop an iOS app which interacts with files outside of that app's sandbox, just running on the simulator?