6

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.

Community
  • 1
  • 1
Yuvaraj.M
  • 9,741
  • 16
  • 71
  • 100

3 Answers3

11

You can use the sample code to take some hint.

https://github.com/michaeltyson/TPKeyboardAvoiding

I have used it in my projects as well.Hope it helps

Rahul Sharma
  • 3,013
  • 1
  • 20
  • 47
7

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

David
  • 3,285
  • 1
  • 37
  • 54
Mitesh Khatri
  • 3,935
  • 4
  • 44
  • 67
5

Check out the below link from apple documentation with complete explanation and required code

They have talked about for registering for the keyboard appear and disappear notification and alter the rect of your underlaying UIView in the notification method for more go through the below URL.

Moving Content That Is Located Under the Keyboard

Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76