の作成に問題UITableView
があります。割り当てたラベルとステッパーがセルの 1 つに表示されないためです。
これがコードです。誰かが問題を解決できることを願っています。ケース 4 に到達すると、セルに lblVarsta が表示されず、ステッパーのみが表示されます。私はそれをデバッグし、値はそこにありますが、その値のラベルは見えません。ありがとうございました!
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UITextField *inputField;
lblRasa = [[UILabel alloc]initWithFrame:CGRectMake(120, 12, 185, 30)];
lblCuloare = [[UILabel alloc]initWithFrame:CGRectMake(120, 12, 185, 30)];
lblJudet = [[UILabel alloc]initWithFrame:CGRectMake(120, 12, 185, 30)];
lbldate = [[UILabel alloc] initWithFrame:CGRectMake(120, 12, 185, 30)];
inputField = [[UITextField alloc]initWithFrame:CGRectMake(120, 12, 185, 30)];
inputField.adjustsFontSizeToFitWidth = YES;
inputField.borderStyle = UITextBorderStyleRoundedRect;
inputField.tag = indexPath.row;
inputField.delegate = self;
segmentedControl1 = [[UISegmentedControl alloc] initWithFrame:CGRectMake(220, 10, 100, 10)];
segmentedControl2 = [[UISegmentedControl alloc] initWithFrame:CGRectMake(220, 10, 100, 10)];
NSArray * segmentItems = [NSArray arrayWithObjects: @"Da", @"Nu", nil];
// UIDatePicker *pv = [[UIDatePicker alloc] init];
// UIActionSheet *uas = [[UIActionSheet alloc] initWithTitle:@"pv" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Select", nil];
//
// [uas addSubview:pv];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellAccessoryNone reuseIdentifier:CellIdentifier];
}
switch ([indexPath row])
{
case 0:
cell.textLabel.text = @"Nume";
inputField.text = dog?dog.title:@"";
[cell addSubview:inputField];
break;
case 1:
cell.textLabel.text = @"Rasa";
lblRasa.text = dog?dog.rasa:@"";
[cell addSubview:lblRasa];
break;
case 2:
cell.textLabel.text = @"Culoare";
lblCuloare.text = dog?dog.culoare:@"";
[cell addSubview:lblCuloare];
break;
case 3:{
cell.textLabel.text = @"Data nasterii";
lbldate.text = dog?dog.data_nas:@"";
[cell addSubview:lbldate];
[cell addSubview:actionSheet];
break;}
case 4:{
lblVarsta = [[UILabel alloc] initWithFrame:CGRectMake(120, 12, 185, 30)];
stepper = [[UIStepper alloc] initWithFrame:CGRectMake(220, 10, 100, 10)];
cell.textLabel.text = @"Varsta";
//inputField.text = dog?[NSString stringWithFormat:@"%d",dog.varsta]:@"";
lblVarsta.text = @"3 ani";
[stepper addTarget:self action:@selector(stepperValueChanged:) forControlEvents:UIControlEventValueChanged];
[lblVarsta setTextColor:[UIColor whiteColor]];
[lblVarsta setBackgroundColor:[UIColor clearColor]];
//[lbl5 setTextAlignment:UITextAlignmentLeft];
[stepper setStepValue:10];
[cell addSubview:lblVarsta];
[cell.contentView addSubview:stepper];
break;}
case 5:
cell.textLabel.text = @"Proprietar";
inputField.text = dog?dog.proprietar:@"";
[cell addSubview:inputField];
break;
case 6:
cell.textLabel.text = @"Judet";
lblJudet.text = dog?dog.judet:@"";
[cell addSubview:lblJudet];
break;
case 7:
cell.textLabel.text = @"Adresa";
inputField.text = dog?dog.adresa:@"";
[cell addSubview:inputField];
break;
case 8:{
cell.textLabel.text = @"Parinti";
//inputField.text = dog?dog.parinti:@"";
//lblVarsta.text = [NSString stringWithFormat:@"%.f", stepper.value];
segmentedControl1 = [[UISegmentedControl alloc] initWithItems: segmentItems];
// segmentedControl1.segmentedControlStyle = UISegmentedControlStyleBar;
// segmentedControl1.selectedSegmentIndex = 0;
[segmentedControl1 addTarget:self action:@selector(segmentedControlIndexChanged:) forControlEvents:UIControlEventValueChanged];
[cell.contentView addSubview:segmentedControl1];
break;}
case 9:
cell.textLabel.text = @"Pedigree";
segmentedControl1 = [[UISegmentedControl alloc] initWithItems: segmentItems];
[segmentedControl1 addTarget:self action:@selector(segmentedControlIndexChanged:) forControlEvents:UIControlEventValueChanged];
[cell.contentView addSubview:segmentedControl2];
break;
}
return cell;
}