title: ios - adding text fields to uitableviewcell programmatically not working
body: <p>Rookie ios question. I am trying to create a sign up form using a table view controller. I am trying add textfields to each cell programmatically in the cellForRowAtIndexPath method but all my text fields seem to getting created on the first cell - one overlapping the other. Here is my code. </p>
  
  <p>Here is how my cells are rendering. I think I am doing something goofy with the part that is reusing the cells. I did check some some other similar threads on stackoverflow but none of them helped. Could you please tell me what i am missing or is this even the way this is supposed to be done. Your inputs are really appreciated.</p>
  
  <p>Thanks,
  Mike</p>
  
  <p><img src="https://i.imgur.com/Z7bHEOO.png" alt=""> </p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"signUpFields" forIndexPath:indexPath];
  
  // Configure the cell...
  if (indexPath.row == 0){
      //self.firstName = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)];
      self.firstName = [[UITextField alloc] initWithFrame:CGRectMake(120, 13, 375, 30)];
      self.firstName.placeholder = @"First Name";
      self.firstName.autocorrectionType = UITextAutocorrectionTypeNo;
      [self.firstName setClearButtonMode:UITextFieldViewModeWhileEditing];
      //cell.accessoryView = self.firstName;
      [cell.contentView addSubview:self.firstName];
  }
  
  if (indexPath.row == 1){
      self.lastName = [[UITextField alloc] initWithFrame:CGRectMake(120, 13, 375, 30)];
      self.lastName.placeholder = @"Last Name";
      self.lastName.autocorrectionType = UITextAutocorrectionTypeNo;
      [self.lastName setClearButtonMode:UITextFieldViewModeWhileEditing];
      //cell.accessoryView = self.lastName;
      [cell.contentView addSubview:self.lastName];
  }
  
  if (indexPath.row == 2){
      self.emailId = [[UITextField alloc] initWithFrame:CGRectMake(120, 13, 375, 30)];
      self.emailId.placeholder = @"Email Id";
      self.emailId.autocorrectionType = UITextAutocorrectionTypeNo;
      [self.emailId setClearButtonMode:UITextFieldViewModeWhileEditing];
      //cell.accessoryView = self.emailId;
      [cell.contentView addSubview:self.emailId];
  }
  
  if (indexPath.row == 3){
      self.password = [[UITextField alloc] initWithFrame:CGRectMake(120, 13, 375, 30)];
      self.password.placeholder = @"Password";
      self.password.secureTextEntry = YES;
      self.password.autocorrectionType = UITextAutocorrectionTypeNo;
      [self.password setClearButtonMode:UITextFieldViewModeWhileEditing];
      //cell.accessoryView = self.password;
      [cell.contentView addSubview:self.password];
  }
  
  self.firstName.delegate = self;
  self.lastName.delegate = self;
  self.emailId.delegate = self;
  self.password.delegate = self;
  
  [self.signUpTable addSubview:self.firstName];
  [self.signUpTable addSubview:self.lastName];
  [self.signUpTable addSubview:self.emailId];
  [self.signUpTable addSubview:self.password];
  
  cell.selectionStyle = UITableViewCellSelectionStyleNone;
  return cell;
  
  }
  </code></pre>