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

Dismiss on Drag causes problems #270

Open phoney opened 6 years ago

phoney commented 6 years ago

I have a tableView with Dismiss on Drag set in the storyboard. If I 'drag to dismiss' the bottom contentInset is never restored after the keyboard goes away (and other weird things happen after that).

The keyboardRect in the keyboardWillHide notification always has a height of zero and the code in TPKeyboardAvoiding_keyboardWillHide ignores the notification in that case. If I tap in the tableView or close the keyboard another way things work normally. If I comment out the first four lines in TPKeyboardAvoiding_keyboardWillHide then things work normally even for 'drag to dismiss'

I'm observing this on an iPad on iOS 11.

Is it safe to comment out those four lines?

fl034 commented 6 years ago

I'm having the same issue if I set the keyboardDismissMode to onDrag or interactive. After using the specific gesture to dismiss the keyboard, contentInsets are not being restored.

I did not try phoney's workaround

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);
    }
}