title: iOS scroll to out of view textfield
body: <p>I have problem with a long form in iOS. The form itself is done with a static table view. For the form I needed a toolbar with prev/next and done. In this project I added <a href="http://github.com/SimonBS/BSKeyboardControls" rel="nofollow">BSKeyboardControls</a>, and I've allready done it myself in another project.</p>
  
  <p>The toolbar works fine except when the next or previous textField/textView is out of sight. Then the focus on the former textField won't change and I'm still typing in this text field. When I now scroll manually and the targeted next textfield appears it magically becomes the first responder. This is of course not the expected behabier.</p>
  
  <p>So I figured out I would have to scroll the table view to the respective fields before trying to set them as first responder. But I connot get this done.</p>
  
  <p>I've tried to this with indexPathes</p>
  
  <pre><code>NSIndexPath *path = [self.tableView indexPathForCell:(UITableViewCell *)textField.superview.superview];
  [self.tableView scrollToRowAtIndexPat:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
  </code></pre>
  
  <p>Although the super-superview is a valid (and the right) table cell, the path returned is nil. I also tried some variations</p>
  
  <pre><code>CGPoint point = [self.tableView convertPoint:textField.frame.origin toView:self.tableView];
  NSIndexPath *path = [self.tableView indexPathForRowAtPoint:point];
  </code></pre>
  
  <p>and other variations with rects and indexPathsForRowsInRect. </p>
  
  <p>The only way is to manually keep track of the textFields cell indexPaths, but that is no suitable solution in this case.</p>
  
  <p>Anybody has an idea of how to achieve scrolling to an out of sight textField in a tableView?</p>
  
  <p>Edit:</p>
  
  <p>As Justin Paulson requested the code of keyboardControlsPreviousNextPressed:</p>
  
  <pre><code>- (void)keyboardControlsPreviousNextPressed:(BSKeyboardControls *)controls withDirection:(KeyboardControlsDirection)direction andActiveTextField:(id)textField
  {
      NSIndexPath *path = [self.tableView indexPathForCell:(UITableViewCell *)((UIView *)textField).superview.superview];
      NSLog(@"path %@ for cell %@", path, ((UIView *)textField).superview.superview);
      [self.tableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
      [textField becomeFirstResponder];
  }
  </code></pre>
  
  <p>As I said according to the output of the log the path is nil, whereas the super-superview is the rught table view cell</p>