0
我按照Apple文檔在鍵盤出現時向上移動文本框。 代碼工作正常我的問題是,我需要一個特定的文本字段向另一個移動,而不是執行代碼蘋果每個我選擇的文本字段向上移動...我怎樣才能移動一個特定的文本字段,而不是所有?鍵盤顯示時移動特定的UITextField
非常感謝你,我插入下面的代碼使用
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
}
// Called when the UIKeyboardDidShowNotification is sent.
- (void)keyboardWasShown:(NSNotification*)aNotification {
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGRect bkgndRect = changePasswordTextField.superview.frame;
bkgndRect.size.height -= kbSize.height;
[scrollView setContentOffset:CGPointMake(0.0, changePasswordTextField.frame.origin.y+kbSize.height) animated:YES];
}
// Called when the UIKeyboardWillHideNotification is sent
- (void)keyboardWillBeHidden:(NSNotification*)aNotification {
[scrollView setContentOffset:CGPointZero animated:YES];
}