Pages

Subscribe:

Labels

Showing posts with label move up. Show all posts
Showing posts with label move up. Show all posts

Sep 14, 2010

UITableView with Textfield Controls auto Moved Up on select

This example shows a signup page with UITextFields and UILabels. When a field is selected by a user then it doesn't get overlapped by the keypad, textfields automatically moves up on select and auto moves down on 'done' button click.
Remember, you can easily implement same concept using UITableViewController, but in that case there will not be more customization options like, static background image etc. So this example is based on UIViewController with UITableViewDelegate.
The method bellow works for moving up and down of whole TableView

- (void) moveToUpDownAnimation:(NSInteger) upOrDown:(NSInteger) yAxis {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
itemTableView.frame = CGRectMake(itemTableView.frame.origin.x, (itemTableView.frame.origin.y + yAxis), itemTableView.frame.size.width, 368);
heading.frame = CGRectMake(heading.frame.origin.x, (heading.frame.origin.y + yAxis), heading.frame.size.width, heading.frame.size.height);
[UIView commitAnimations];
}

You may download the sample app from here