2行n4セクションのuitableviewがあり 、各セルにラベルとテキストフィールドがあります。そして問題は、私のラベルがすべてのセクションにあるのに、私のテキストフィールドが他のセクションで繰り返されていないことです。実際、セルごとに2つのテキストフィールドがあります。1つは通常のテキストフィールドで、もう1つはピッカーテキストフィールドです(TFをクリックするとピッカーがポップアップ表示されます)。1つのセクションでは、両方のTFが発生しますが、他のセクションでは繰り返されません。
私のコード
static NSString *CellIdentifier = @"Cell";
UITextField *textField;
NSString *string=[NSString stringWithFormat:@"ident_%d",indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:string];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;
UILabel *lbl1 = [[UILabel alloc]initWithFrame:CGRectMake(50, 10, 100, 35)];
[lbl1 setFont:[UIFont systemFontOfSize:16]];
[lbl1 setTextColor:[UIColor blackColor]];
[lbl1 setBackgroundColor:[UIColor clearColor]];
if (indexPath.row==0) {
lbl1.text = @"Quantity";
[cell.contentView addSubview:self.qntTF];
}
if (indexPath.row==1) {
lbl1.text = @"Unit";
[cell.contentView addSubview:self.unitTF];
}
// Configure the cell...;
textField =[self.tableArray objectAtIndex:indexPath.row];
[cell.contentView addSubview:textField];
cell.textLabel.text = nil;
textField.tag = TextFieldTag;
cell.detailTextLabel.text = nil;
[cell addSubview:lbl1];
[lbl1 release];
return cell;