2011-04-21 50 views
1

我有一個文本框在UITableView頁腳中輸入代碼。滾動查看UITableView頁腳中的文本框

當我點擊文本框,我得到出現在鍵盤,但我不知道我怎麼能得到的UITableView以使文本框可見

任何代碼示例這個滾動?

回答

0

接到一個以前的SO問題,此代碼。

- (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]; 
    }