michaeltyson / TPKeyboardAvoiding

A drop-in universal solution for moving text fields out of the way of the keyboard in iOS
http://atastypixel.com/blog/a-drop-in-universal-solution-for-moving-text-fields-out-of-the-way-of-the-keyboard/
zlib License
5.81k stars 925 forks source link

When keyboard is dismissed, view controller's height doesn't return to its original value. #271

Closed AlbertoMalavasi closed 5 years ago

AlbertoMalavasi commented 6 years ago

Once the keyboard has been opened, the view's height increases to a specific number of points, but when I close the keyboard that views doesn't go back to its original (height) size.

My container view is made by several collection views and views containing labels. I'm using the keyboard avoiding scroll view class.

maomaoshou commented 5 years ago

Once the keyboard has been opened, the view's height increases to a specific number of points, but when I close the keyboard that views doesn't go back to its original (height) size.

My container view is made by several collection views and views containing labels. I'm using the keyboard avoiding scroll view class.

Have you solved your problem,I have the same problem

AzamRahmat commented 5 years ago

try this. func textFieldDidEndEditing(_ textField: UITextField, reason: UITextFieldDidEndEditingReason) {

    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1){[weak self]  in
        self?.scrollView.contentInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);
    }
}
ihugang commented 5 years ago

NOT solved. still scroll :(

try this. func textFieldDidEndEditing(_ textField: UITextField, reason: UITextFieldDidEndEditingReason) {

    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1){[weak self]  in
        self?.scrollView.contentInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);
    }
}
maomaoshou commented 5 years ago

Does anyone has solutions?

uclort commented 5 years ago

- (void)TPKeyboardAvoiding_keyboardWillHide:(NSNotification*)notification

CGRect keyboardRect = [self convertRect:[[[notification userInfo] objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil];

modified to

CGRect keyboardRect = [self convertRect:[[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:nil];