1

I have an app built for iOS 5 that I'm trying to upgrade straight to iOS 7, so this also maybe an issue with iOS 6.

We have a UITextField inside a custom table view cell (class derived from UITableCellView), but tapping on it no longer brings up the keyboard in the simulator. Everything is enabled, and User Interaction Enabled is checked.

It used to work fine in iOS 5.

I'm not sure what code to include, but here's the code that creates the cell... the LoginRegisterTableViewCell just has a 'fieldLabel' (UILabel) and 'userText' (UITextField):

    // Login area
    static NSString * reuseIdentifier = @"LoginRegisterTableViewCell";

    LoginRegisterTableViewCell * cell = (LoginRegisterTableViewCell *)[tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if(cell == nil)
    {
        // The official Apple way of loading TableViewCell nibs
        // http://www.nomadplanet.fr/2011/01/custom-uitableviewcells-loaded-from-xib-howto-debug/
        [[NSBundle mainBundle] loadNibNamed:@"LoginRegisterTableViewCell" owner:self options:nil];
        cell = formFieldCell;
        self.formFieldCell = nil;
    }

    cell.delegate = self;
    cell.userText.tag = [indexPath row];

I can get the keyboard to come up if I call [userText becomeFirstResponder] when the table cell is selected, but this seems like a workaround as opposed to the correct way.

Richard Lovejoy
  • 663
  • 10
  • 18

1 Answers1

1

Try this code with the table view data source: cellForRowAtIndexPath

    NSString *cellReuseIdentifier = @"CellIdentifier";
    UINib *nib = [UINib nibWithNibName:@"CustomTableViewCell" bundle:nil];
   [_myTableView registerNib:nib forCellReuseIdentifier:cellReuseIdentifier];

    CustomTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellReuseIdentifier];
    if (!cell)
    {
        cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellReuseIdentifier];
    }

    return cell;

It is working for me with the custom cell created with the xib as shown in the image enter image description here

Note: Mark Also create XIB file.

And give a cell reuse identifier likeenter image description here

This is working for me well for the sample application with no issue with the keyboard.

Alex Andrews
  • 1,498
  • 2
  • 19
  • 33
  • It worked. I think my setup was pretty archaic and a few years old. Thanks – Richard Lovejoy Jul 03 '14 at 14:05
  • @RichardLovejoy : It is very simple and better to use storyboard than Nib to create custom TableView Prototype Cells with custom cell classes for managing the contents of the cell dynamically. Refer this tutorial from raywenderlich . http://www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1 – Alex Andrews Jul 04 '14 at 10:04