iOS not able to update the set text in UITextField

521 Views Asked by At

I have a UITextField in UITableViewCell the text property is not updating.

My tableview delegate:

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath {
KAPInputTableViewCell *cell = [self.registerTableView
                         dequeueReusableCellWithIdentifier:KAPInputCellIdentifier];
if (!cell) {
    cell = [[KAPInputTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                 reuseIdentifier:KAPInputCellIdentifier];
}

switch (indexPath.row) {
    case 0:
        cell.inputTextField.placeholder = KAPLocalizedString(@"email", @"E-mail address");
        cell.inputTextField.text = @"Test";
        cell.tag = 0;
        cell.errorLabel.text = self.emailError;
        self.emailCell = cell;
        self.emailTextField = cell.inputTextField;
        break;
}
cell.inputTextField.delegate = self;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}

Then when I call,

NSLog(@"%@", self.emailTextField.text);

Later in my ViewController on the press of a button the edited text still returns "Test" while I changed the input value.

Please help.

1

There are 1 best solutions below

0
On

I think you should just implement the UITextField delegate method:

   - (void)textFieldDidEndEditing:(UITextField *)textField{
    NSLog(@"%@", textField.text);
   }

Here you will see your textField updated.