カスタムテーブルcell試し

色々あると思うけど、自分的なInterfaceBuilder使わないカスタムテーブルCellメモ

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *indentifier = @"なまえ";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    
    UILabel *nameLabel , *statusLabel;

    nameLabel = [[[UILabel alloc] initWithFrame:CGRectMake(70.0, 0.0, 250.0, 25.0)] autorelease];
    nameLabel.tag = 1;

    statusLabel = [[[UILabel alloc] initWithFrame:CGRectMake(70.0, 25.0, 250.0, 10.0)]autorelease];
    statusLabel.tag = 2;

    statusLabel.font = [UIFont systemFontOfSize:10.0];
    statusLabel.textColor = [UIColor darkGrayColor];
    
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier] autorelease];
    }else {
        nameLabel = (UILabel *)[cell.contentView viewWithTag:1];
    }
    
    NSInteger row = [indexPath row];
    NSString *tableLabelText = [テキストArray objectAtIndex:row];
    UIImage *img = [イメージArray objectAtIndex:row];
    
    nameLabel.text = tableLabelText;
    statusLabel.text = @"ラベル";
    cell.imageView.image = img;
    
    [cell.contentView addSubview:nameLabel];
    [cell.contentView addSubview:statusLabel];
    
    return cell;
}

UILabelのCGRectMakeのところをもっと上手に書く方法はないものか