Я создал по меньшей мере 10 ячеек с каждым UITextField, на странице регистрации. Когда я вставляю слова в текстовое поле в первой ячейке, и когда я прокручиваю tableView, текстовое поле, находящееся в другой ячейке, отображает слово, которое я только что напечатал.Проблема с отображением UITextField в ячейке TableView
Ниже приведен мой код. Данные textField, которые я вводил, являются циклическими, что вызвано dequeueReusableCellWithIdentifier ... Как я могу решить эту проблему? Большое спасибо.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"RCell";
RegisterCell *cell = (RegisterCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[[RegisterCell alloc] initWithFrame:CGRectMake(0, 0, 280, 44) reuseIdentifier:CellIdentifier] autorelease];
if(indexPath.section == 0){
NSDictionary *rowData = [self.regisLabel objectAtIndex:[indexPath row]];
NSString *mainLabel = [NSString stringWithFormat:@"%@", [rowData objectForKey:@"regisLbl"]];
cell.registerLabel.text = mainLabel;
UITextField *valTxtField = [[UITextField alloc] initWithFrame:CGRectMake(120, 5, 180, 30)];
valTxtField.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:18.0];
valTxtField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
valTxtField.delegate = self;
valTxtField.returnKeyType = UIReturnKeyDone;
valTxtField.autocorrectionType = UITextAutocorrectionTypeNo;
valTxtField.autocapitalizationType = UITextAutocapitalizationTypeNone;
if(indexPath.row == 0)
{
valTxtField.text = @"";
emailTxtFld = valTxtField; //emailTxtFld is global variable
}
if(indexPath.row == 1)
{
valTxtField.text = @"";
reEmailTxtFld = valTxtField; //reEmailTxtFld is global variable
}
[cell.contentView addSubview:valTxtField];
[valTxtField release];
}
else if(indexPath.section == 1){
NSDictionary *rowData = [self.regisLabel objectAtIndex:[indexPath row]+10];
NSString *mainLabel = [NSString stringWithFormat:@"%@", [rowData objectForKey:@"regisLbl"]];
cell.registerLabel.text = mainLabel;
cell.registerTextField.enabled = NO;
}
else if(indexPath.section == 2){
if(indexPath.row == 0){
NSDictionary *rowData = [self.regisLabel objectAtIndex:[indexPath row]+11];
NSString *mainLabel = [NSString stringWithFormat:@"%@", [rowData objectForKey:@"regisLbl"]];
cell.registerLabel.text = mainLabel;
cell.registerTextField.enabled = NO;
}
}
return cell;
}