Note that there are some explanatory texts on larger screens.

plurals
  1. POProgramatically manipulating UITextField in cell that was created in storyboard
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/nZT9C.png" alt="Here is the View"></p> <p>I'm trying to change the UITextField in a TableView delegate</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString * CellIdentifier = @"CellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if ( cell == nil ) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } // Configure cell here if ( indexPath.section == [self nameSectionNumber]) { if ( indexPath.row == [self firstNameRowNumber] ){ UITextField *textFieldFromCell = [self retrieveUITextFieldFromCell:cell]; textFieldFromCell.text = [self.person firstName]; } else if ( indexPath.row == [self lastNameRowNumber] ) { cell.textLabel.text = [self.person lastName]; } } else if ( indexPath.section == [self emailSectionNumber] ) { if ( indexPath.row == [self emailSectionHomeRowNumber] ) { cell.textLabel.text = [self.person homeEmail]; } else if ( indexPath.row == [self emailSectionWorkRowNumber] ) { cell.textLabel.text = [self.person workEmail]; } } return cell; } - (UITextField *)retrieveUITextFieldFromCell:(UITableViewCell *)cell { // Need to grab UITextField from cell for (UIView *view in cell.contentView.subviews){ if ([view isKindOfClass:[UITextField class]]){ UITextField* txtField = (UITextField *)view; return txtField; } } return nil; } </code></pre> <p>If I don't try to modify the cell and just do</p> <pre><code>// Configure cell here if ( indexPath.section == [self nameSectionNumber]) { if ( indexPath.row == [self firstNameRowNumber] ){ cell.textLabel.text = [self.person firstName]; } else if ( indexPath.row == [self lastNameRowNumber] ) { cell.textLabel.text = [self.person lastName]; } } </code></pre> <p>The UILabel ("First Name") is gone and the UITextField is gone, which is what I expect since I think its because of this code</p> <pre><code> UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if ( cell == nil ) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } </code></pre> <p><img src="https://i.stack.imgur.com/lFmm2.png" alt="Second view"></p> <p>Note: Ignore the last name and email fields. I'm only focusing on first name at the moment to get that to look right.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload