简体   繁体   English

TPKeyboardAvoidingScrollView问题

[英]Issue with TPKeyboardAvoidingScrollView

I'm using TPKeyboardAvoidingScrollView for moving view up when keyboard appears. 我正在使用TPKeyboardAvoidingScrollView在键盘出现时向上移动视图。 It is working perfectly when I return my keyboard in a normal speed. 当我以正常速度返回键盘时,它可以正常工作。 But when I return the keyboard with the speed higher than normal. 但是当我以高于正常速度返回键盘时。 Then the view stuck to the top and doesn't move down. 然后视图停留在顶部,而不会向下移动。

Any idea? 任何想法? Any of you have seen this kind of problem before? 你们当中有人见过这种问题吗?

Any help is appreciated!! 任何帮助表示赞赏!

I solved the problem by modifying following method. 我通过修改以下方法解决了该问题。 Take a look at the difference here. 看看这里的区别。

Before: 之前:

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

After: 后:

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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM