У меня есть эта страница, в которой каждая ячейка отличается, поэтому я делаю это как код ниже, но почему-то я считаю, что ее можно оптимизировать, любые идеи, я должен использовать пользовательскую ячейку, но если да, то у меня есть создать 12 пользовательских ячеек, поскольку каждая ячейка имеет совершенно другую раскладкуUitableview different cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
// }
if (indexPath.row==0)
{
UILabel *lbl_label = [[UILabel alloc] initWithFrame:CGRectMake(15, 7, 200, 25)];
lbl_label.text = @"PRICE";
[lbl_label setFont:NORMAL_LABEL(16)];
[lbl_label setTextColor:UIColorFromRGB(0x565A5C,1.0)];
UILabel *lbl_price = [[UILabel alloc] initWithFrame:CGRectMake(100, 7, 200, 25)];
lbl_price.text = @"$ 50";
[lbl_price setFont:NORMAL_LABEL(16)];
[lbl_price setTextColor:[UIColor grayColor]];
[lbl_price setTextColor:UIColorFromRGB(0x82898D,1.0)];
lbl_price.textAlignment = NSTextAlignmentRight;
[cell addSubview:lbl_price];
[cell addSubview:lbl_label];
}
else if (indexPath.row==1)
{
UILabel *lbl_label = [[UILabel alloc] initWithFrame:CGRectMake(15, 7, 200, 25)];
lbl_label.text = @"CUISINE";
[lbl_label setFont:NORMAL_LABEL(16)];
[lbl_label setTextColor:UIColorFromRGB(0x565A5C,1.0)];
UILabel *lbl_price = [[UILabel alloc] initWithFrame:CGRectMake(100, 7, 200, 25)];
lbl_price.text = @"Sushi, Japanese, Arabian";
[lbl_price setFont:NORMAL_LABEL(16)];
[lbl_price setTextColor:[UIColor grayColor]];
[lbl_price setTextColor:UIColorFromRGB(0x82898D,1.0)];
lbl_price.textAlignment = NSTextAlignmentRight;
[cell addSubview:lbl_price];
[cell addSubview:lbl_label];
}
else if (indexPath.row==2)
{
UILabel *lbl_label = [[UILabel alloc] initWithFrame:CGRectMake(15, 7, 200, 25)];
lbl_label.text = @"GOOD FOR";
[lbl_label setFont:NORMAL_LABEL(16)];
[lbl_label setTextColor:UIColorFromRGB(0x565A5C,1.0)];
UILabel *lbl_price = [[UILabel alloc] initWithFrame:CGRectMake(100,7, 200, 25)];
lbl_price.text = @"Alcohol, Brunch";
[lbl_price setFont:NORMAL_LABEL(16)];
[lbl_price setTextColor:[UIColor grayColor]];
[lbl_price setTextColor:UIColorFromRGB(0x82898D,1.0)];
lbl_price.textAlignment = NSTextAlignmentRight;
[cell addSubview:lbl_price];
[cell addSubview:lbl_label];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}