问题
I have a form that the user of the app must fill in order to register to the service. However, as there are many fields that need to be filled, some of them are at the bottom of the screen, so when the keyboard appears, the field is covered and the user can't see what's typed.
I'm using a UITableView with custom Prototype Cells, each one has a UITextField named textField.
回答1:
There are a lot of solutions to your problem. You can use this. There's a sample code which handles the keyboard animation for UITableView as well.
回答2:
you move table up when user start typing.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
[UIView beginAnimations:nil context:self.tableView];
[UIView setAnimationDuration:0.25];
[self.view setFrame:CGRectMake(0, -130, 320, 460)];
[UIView commitAnimations];
return YES;
}
回答3:
Hi try this code hope will help
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
UITableViewCell *newcell = (UITableViewCell*) [[textField superview] superview];
[tbl_view scrollToRowAtIndexPath:[tbl_view indexPathForCell:newcell] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
来源:https://stackoverflow.com/questions/15757201/move-uitextfield-in-custom-uitableviewcell-to-the-center-of-the-screen-so-the-ke