Scrolling to view textbox in UITableView footer
I have a textbox to enter a code in UITableView footer.
When I click the text box I get the keyboa开发者_高级运维rd appearing but I am not sure how I could get the UITableView to scroll so that the text box is visible
Any code sample for this?
Got this code from a previous SO question.
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if(textField == birthdayTextField)
[self animateTextField: textField up: YES];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if(textField == birthdayTextField)
[self animateTextField: textField up: NO];
}
- (void) animateTextField: (UITextField*) textField up: (BOOL) up
{
const int movementDistance = 80; //change this around
const float movementDuration = 0.3f; //change this around
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
since the footer cant scroll any higher the the lowest point of the tableview, you will need to move the tableview up to to show the textbox.
There is a nice blogpost here: http://cocoawithlove.com/2008/10/sliding-uitextfields-around-to-avoid.html
精彩评论