title: Table View scroll when text field begin editing iphone
body: <p>I have table view controller in iphone application. Table view has two sections. First section has two rows and second section has one row. Second section has a custom table view cell. </p>
  
  <p>Second section has a textfield which hides when text field begin editing and keyboard pops up. I want this table view to scroll when keyboard pops up.</p>
  
  <p>I tried the following code which I came across on different websites but in vain.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>-(void) textFieldDidBeginEditing:(UITextField *)textField {
  
      CGRect textFieldRect = [textField frame];
      [self.tableView scrollRectToVisible:textFieldRect animated:YES];
  } 
                            atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
  }
  
  -(void) textFieldDidBeginEditing:(UITextField *)textField {
  
      UITableViewCell *cell = (UITableViewCell*) [[textField superview] superview];
      [self.tableView scrollToRowAtIndexPath:[tableView indexPathForCell:cell] 
                            atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
  }
  </code></pre>