Combining multiple UITextFields and a UITableView in a nice way for an iPhone app: part 2

My last blog post was about creating a form for an iPhone application by combining multiple UITextFields in a UITableView. I outlined the problems with this kind of screens. The first problem is the destruction of data already entered when scrolling the field off screen and secondly, app crashes when the field with focus is scrolled off screen and you touch inside another textfield. The solution I proposed was to nest the UITableView inside a UIScrollview. After receiving feedback I came up with a second solution:

  1. extend a UITableViewController instead of implementing UITableviewDataSource and UITableViewDelegate yourself
  2. disable reuse of cells by using a unique cell identifier:
  3. NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%i", indexPath.row];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];



The UITableViewController handles scrolling into view when the keyboard is shown quite nicely. Using the unique identifier will prevent a cell and it’s content to be reused. And I had to agree to some of the feedback: using a UIScrollView to nest a tableView is kind of a hack.

There is a down side to this: UITableViewControllers don’t like to be combined with other view controllers, so you have to use a NavigationController or TabBarController to offer further interaction possibilities. I tried to, but never managed nicely to have for instance a UIToolBar over the UITableView.

Try it out and let me know what you think!

Download XCode project TestTableViewWithKeyboard2 with demo using UITableView to create a form.