TPKeyboardAvoidingScrollView问题

时间:2013-08-22 06:17:34

标签: iphone ios tpkeyboardavoiding

我正在使用TPKeyboardAvoidingScrollView在键盘出现时向上移动视图。当我以正常速度返回键盘时,它工作正常。但是当我以高于正常速度的速度返回键盘时。然后视图粘在顶部而不会向下移动。

有什么想法吗? 你们之前有没有见过这种问题?

任何帮助表示赞赏!!

1 个答案:

答案 0 :(得分:1)

我通过修改以下方法解决了这个问题。看看这里的差异。

<强>之前:

- (void)keyboardWillHide:(NSNotification*)notification
{
    _keyboardRect = CGRectZero;
    _keyboardVisible = NO;

    // Restore dimensions to prior size
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
    [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];

    self.contentInset = _priorInset;

    [self setScrollIndicatorInsets:self.contentInset];
    _priorInsetSaved = NO;

    [UIView commitAnimations];
}

之后:

- (void)keyboardWillHide:(NSNotification*)notification
{
    _keyboardRect = CGRectZero;

    // Restore dimensions to prior size
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
    [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];

    self.contentInset = _priorInset;

    [self setScrollIndicatorInsets:self.contentInset];
    _priorInsetSaved = NO;

    [self adjustOffsetToIdealIfNeeded];

    [UIView commitAnimations];

    _keyboardVisible = NO;

}