-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AlertView offset is not restored after dismissing keyboard #265
Comments
Thanks for reporting, I'll try to look at this soon. |
Fixed it temporarily by saving the Y offset for the popup view, when the keyboard shows/hides, and then setting the y offset on these events. |
I think this is fixed on https://github.com/sberrevoets/SDCAlertView/tree/handle-keyboard-dismiss. Can you check it out and see if this solves your problem? |
Not working on my side. |
@mureatencio on the branch I provided above? I was able to reproduce the issue, but not anymore on that branch. |
In function listenForKeyboardChanges I replace function with private func listenForKeyboardChanges() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
} and add two function with @objc private func keyboardWillShow(notification: NSNotification) {
let newFrameValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue
guard let newFrame = newFrameValue?.cgRectValue else {
return
}
self.verticalCenter?.constant = -newFrame.height / 2
self.alert.layoutIfNeeded()
}
@objc private func keyboardWillHide(notification: NSNotification){
self.verticalCenter?.constant = 0
self.alert.layoutIfNeeded()
} |
Did you change master or handle-keyboard-dismiss branch? I've tried both and it doesn't work on master and on handle-keyboard-dismiss I'm getting crash on device when accessing alert.contentView (just after AlertController creation). |
I'm not aware of any changes that would cause a crash, though the other branch is obviously a bit outdated at this point. |
Can you tell me how to implement this keyboard dismiss fix on master branch? |
The change above suggested by @x10geeky worked fine for me. 👏 @twostraws in here suggested that Any chance to get that on the master branch? |
I am using
and
to dismiss keyboard when blank area is tapped, the alertview stay at the position where it was pushed to by keyboard.
The text was updated successfully, but these errors were encountered: