Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

erdinc27

macrumors regular
Original poster
Jul 20, 2011
168
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.
 
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....
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.