UITableViewCell:
1.使用系统自定义的各种UITableViewCell的样式
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString* indentifier = @"cell";
MyTableCell* cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
if (!cell) {
/*
typedef NS_ENUM(NSInteger, UITableViewCellStyle) {
UITableViewCellStyleDefault, // Simple cell with text label and optional image view (behavior of UITableViewCell in iPhoneOS 2.x)
UITableViewCellStyleValue1, // Left aligned label on left and right aligned label on right with blue text (Used in Settings)
UITableViewCellStyleValue2, // Right aligned label on left with blue text and left aligned label on right (Used in Phone/Contacts)
UITableViewCellStyleSubtitle // Left aligned label on top and left aligned label on bottom with gray text (Used in iPod).
};
*/
cell = [[[MyTableCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier]autorelease];
}
cell.textLabel.text = [_data objectAtIndex:indexPath.row];
cell.detailTextLabel.text = @"detail";
cell.imageView.image = [UIImage imageNamed:@"checkmark.png"];
return cell;
}
使用UITableViewCellStyleDefault的效果:
使用UITableViewCellStyleValue1的效果: