这是运营顺序的问题

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];    
[nc addObserver:self 
       selector:@selector(keyboardWillShow:) 
           name:UIKeyboardWillShowNotification 
         object:nil];
[nc addObserver:self 
       selector:@selector(keyboardWillHide:) 
           name:UIKeyboardWillHideNotification 
         object:nil];

然后,我将文本框添加到UitaiteViewCell:

[textField addTarget:self 
              action:@selector(textFieldBegin:) 
    forControlEvents:UIControlEventEditingDidBegin];

[cell addSubview:textField];

在TextFieldBegin中,我滚动滚动到正在编辑的单元格中。
在键盘上,我调整了表图的框架以允许键盘。
textfieldbegin 被调用 键盘意见, ,因此第一次证明它没有滚动的空间。

是否有一种解决此监督的大力方法?

有帮助吗?

解决方案

您可以在开始期间将当前的滚动位置存储在变量中,然后在键盘WillShow Notification中将其重新滚动到该变量中存储的任何位置。

我认为这将使您能够将不同的动画保留在它们所属的位置。

其他提示

而不是听 UIKeyboardWillShowNotification 您可以对uitextfielddelegate方法做出反应 textFieldDidBeginEditing: 并在该方法中调整/滚动大小,因为它被称为 显示键盘。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top