Custom UITableViewCell's set tag

Discussion in 'iOS Programming' started by erdinc27, Aug 6, 2018.

  1. erdinc27 macrumors regular

    Joined:
    Jul 20, 2011
    #1
    I have an UITableViewController and it is registered for multiple UITableViewCells. In a cell there is a UITextField and I can't set its tag property. It is always taken from Xib file. It doesn't get tag from the code. Here the code I use. What is wrong here?
    Code:
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
       if (indexPath.section == 1) {
            TextTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TextFieldTableCell forIndexPath:indexPath];
            cell.delegate = self;
            cell.theTextField.tag = InputTypeCompanyName;
            NSString *savedString = [self.coreDataWrapper getTheValueOfTextFieldWithAttribute:COMPANY_NAME];
            if (![savedString isEqualToString:@""]) {
                cell.theTextField.text = savedString;
            }
            return cell;
           
        } else if (indexPath.section == 4) {
            TextTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TextFieldTableCell forIndexPath:indexPath];
            cell.delegate = self;
           
            if (indexPath.row == 0) {
                cell.theTextField.placeholder = @"Kullanıcı adı";
                cell.theTextField.tag = InputTypeCustomerName;
                NSString *savedString = [self.coreDataWrapper getTheValueOfTextFieldWithAttribute:CUSTOMER_NAME];
                if (![savedString isEqualToString:@""]) {
                    cell.theTextField.text = savedString;
                }
               
            } else {
                cell.theTextField.placeholder = @"Şifre";
                cell.theTextField.tag = InputTypeCustomerPassword;
                NSString *savedString = [self.coreDataWrapper getTheValueOfTextFieldWithAttribute:CUSTOMER_PASSWORD];
                if (![savedString isEqualToString:@""]) {
                    cell.theTextField.text = savedString;
                }
            }
           
            return cell;
           
        } else {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingsCellIdentifier forIndexPath:indexPath];
            return cell;
        }
    
    }
    I expect here the textfield tag should be 1,2 or 3 but it gets always 0 or any value in the xib file.
     
  2. PhoneyDeveloper macrumors 68040

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
  3. albebaubles macrumors 6502

    albebaubles

    Joined:
    Feb 9, 2010
    Location:
    low Sierra
    #3
    I expect here the textfield tag should be 1,2 or 3 but it gets always 0 or any value in the xib file.[/QUOTE]


    Where's the definition of those tag fields (InputTypeCustomerPassword...)
    ? maybe debug the app and check their values....
     

Share This Page