Pages

Subscribe:

Labels

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

1 comment:

Anonymous said...

Hello there! Do you use Twitter? I'd like to follow you if that would be

ok. I'm definitely enjoying your blog and look forward to new
posts.

Here is my weblog ... www.cesja.pl

Post a Comment