Search code examples
iphoneuitableviewkeyboardscrollappearance

How to scroll the UITableviewcell scroll up when the keyboard appears?


Possible Duplicate:
Table View scroll when text field begin editing iphone

I have loaded many UITextFields in UITableview. Maximum i have 15 UITextFields in UITableView cells. I want to move(Scroll) up the the Cell when the Keyboard/UIActionSheet(UIPickerView) appears. Please suggest/guide me any sample code to solve this problem. Thanks in advance.


Solution

  • Please try below code in -textFieldShouldBeginEditing ....

    self.tblView.frame= CGRectMake(self.tblView.frame.origin.x, self.tblView.frame.origin.y, self.tblView.frame.size.width, self.tblView.frame.size.height - 190);
    NSIndexPath *indexPath =[NSIndexPath indexPathForRow:nIndex inSection:nSectionIndex];
    [self.tblView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
    

    Thanks