Une approche alternative pourrait être d'utiliser un UITableView. Alors la plupart des contrôles sont prêts. Mais vous pouvez aussi tout faire par vous-même.
Placez d'abord vos champs UITextfield sur un UIView distinct. Faites de UIView un point de vente en le reliant correctement. De cette façon, vous pouvez facilement déplacer les champs de texte avec une animation.
faire quelque chose comme cela dans les méthodes de délégués:
// Sets the label of the keyboard's return key to 'Done' when the insertion
// point moves to the table view's last field.
//
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if ([textField tag] == myLastUITextField)
{
[textField setReturnKeyType:UIReturnKeyDone];
}
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if ([textField returnKeyType] != UIReturnKeyDone)
{
// If this is not the last field (in which case the keyboard's
// return key label will currently be 'Next' rather than 'Done'),
// just move the insertion point to the next field.
//
NSInteger nextTag = [textField tag] + 1;
UIView *nextTextField = [myTextView viewWithTag:nextTag];
// here starts your animation code
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = textFieldView.frame;
rect.origin.y = -44;
textFieldView.frame = rect;
[UIView commitAnimations];
// here ends your animation code. Play with it
[nextTextField becomeFirstResponder];
}
else
{
// do what you want to do with the last UITextfield
}
return YES;
}
`
je pense que ce ne sera pas immédiatement travailler par copier-coller, mais je l'espère, elle pointe dans une direction. Bonne chance