Hi all,
Note: I'm using iPhone SDK 3.0 Final Version for Leopard.
I need to prepare a table listing similar to the one used by iPhone's Photo Album application. There are two new styles for UITableViewCell:
UITableViewCellStyleValue1
UITableViewCellStyleValue2
I thought i can use these instead of creating a custom cell class, but looks like they don't work properly. I'm facing following issues with UITableViewCellStyleValue2
:
- I'm unable to show an image.
- If i change the font size of
textLabel
anddetailTextLabel
, the values are not aligned.
Here's the sample code:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.imageView.image = [UIImage imageNamed:@"Pointy.gif"];
cell.textLabel.text = @"Label";
cell.textLabel.textColor = [UIColor redColor];
cell.textLabel.font = [UIFont systemFontOfSize:21];
cell.detailTextLabel.text = @"(10)";
cell.detailTextLabel.textColor = [UIColor grayColor];
cell.detailTextLabel.font = [UIFont systemFontOfSize:17];
return cell;
}
This piece of code work with UITableViewCellStyleDefault
and UITableViewCellStyleSubtitle
to show images. Does UITableViewCellStyleValue2
support cell image property? I see blank space in place of image area (left corner of the cell). Am i doing something wrong here?
In case this doesn't work, how can i build a custom cell class with a style similar to UITableViewCellStyleValue2
style. I'm particularly interested in getting the detailTextLabel
left aligned with textLabel
.
Thanking in anticipation.