2010-11-01 4 views
0

J'ai une liste des UITextFields.Aidez-moi sur UITextField

Je veux passer aux champs de texte suivants un par un après avoir entré une entrée dans celui-ci.

depuis le clavier se cache les champs ....

peut vous montrer que les gens me Comment puis-je accomplir cela ...

Merci beaucoup pour votre temps.

Répondre

2
  • (void) shiftViewUp: (BOOL) jusqu'à {

[UIView beginAnimations: contexte nul: NULL];

[UIView setAnimationDuration:0.3]; 

CGRect rect = self.view.frame; 
if (movedUp) 
{ 

    if(rect.origin.y == 0){ 
     rect.origin.y -= 85.0; 
     rect.size.height += 85.0; 
    } 
} 
else 
{ 

    if(rect.origin.y != 0.0){ 
     rect.origin.y += 85.0; 
     rect.size.height -= 85.0; 
    } 
} 

self.view.frame = rect; 

[UIView commitAnimations]; 

}

Fondamentalement, vous pouvez appeler cette méthode avec BOOL OUI lorsque vous commencez à modifier le textfiled & avec BOOL pas lorsque vous mettez fin d'édition. Vous avez juste besoin de suivre quel champ de texte édite basé sur ce que vous pouvez ajuster le décalage (par exemple 85 ici)

1

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