У меня есть таблица с ячейками, в каждой из которых есть UITextField
. Прямо сейчас я вручную устанавливаю эти данные из NSDictionary
для каждой ячейки, и я устанавливаю свойство UITextField для UITextField каждой ячейки. Это устанавливает текст textField
на текст из словаря, если он есть, но если его нет, я хочу, чтобы пользователь мог установить текст в новый NSDictionary, который я могу загрузить обратно на сервер.
Но я думаю, мне нужно создать NSDictionary
для хранения новых значений. Прямо сейчас текст в ячейках стирается и используется случайным образом при прокрутке таблицы.
else if (tableView == self.vitalsTableView)
{
if ([indexPath row] == 2) {
CellIdentifier = @"bloodPressureCell";
BloodPressureTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
self.bloodPressureTextField1 = cell.textField1;
self.bloodPressureTextField2 = cell.textField2;
return cell;
}
else if ([indexPath row] == 9){
CellIdentifier = @"statusCell";
SmokingStatusTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
return cell;
}
else if ([indexPath row] == 10){
CellIdentifier = @"vitalsCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
return cell;
}
else{
CellIdentifier = @"textCell";
VitalsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
switch (indexPath.row) {
case 0:
cell.vitalsLabel.text = @"Temperature";
cell.textField.text = [self.childAppointmentDictionary objectForKey:@"temperature"];
self.temperatureTextField = cell.textField;
break;
case 1:
cell.vitalsLabel.text = @"Pulse";
cell.textField.text = [self.childAppointmentDictionary objectForKey:@"pulse"];
self.pulseTextField = cell.textField;
break;
case 3:
cell.textField.text = [self.childAppointmentDictionary objectForKey:@"respiratory_rate"];
self.respiratoryRateTextField = cell.textField;
break;
case 4:
cell.vitalsLabel.text = @"Oxygen Saturation";
cell.textField.text = [self.childAppointmentDictionary objectForKey:@"oxygen_saturation"];
self.oxygenSaturationTextField = cell.textField;;
break;
case 5:
cell.vitalsLabel.text = @"Height";
cell.textField.text = [self.childAppointmentDictionary objectForKey:@"height"];
self.heightTextField = cell.textField;
break;
case 6:
cell.vitalsLabel.text = @"Weight";
cell.textField.text = [self.childAppointmentDictionary objectForKey:@"weight"];
self.weightTextField = cell.textField;
break;
case 7:
cell.vitalsLabel.text = @"BMI";
cell.textField.text = [self.childAppointmentDictionary objectForKey:@"bmi"];
self.bmiTextField = cell.textField;
break;
case 8:
cell.vitalsLabel.text = @"Pain (1-10)";
cell.textField.text = [self.childAppointmentDictionary objectForKey:@"pain"];
self.painTextField = cell.textField;
break;
default:
break;
}
return cell;
}
}