0

For a long while now, I've been looking for a Swift implementation that utilizes UIKeyboardWillChangeFrameNotification so far I haven't come across anything. I'm trying to get this working so that I can handle the keyboard show and hide in one method as stated in the documentation here and here written in objective-c.

and replace these:

// Register your Notification, To know When Keyboard appears.
NotificationCenter.default.addObserver(self, selector: #selector(myKeyboardWillShowMethod), name: .UIKeyboardWillShow, object: nil)

// Register your Notification, To know When Keyboard hides.
NotificationCenter.default.addObserver(self, selector: #selector(myKeyboardWillHideMethod), name: .UIKeyboardWillHide, object: nil)
  • If you know how to write the code for those two notifications, what problem are you having with the UIKeyboardWillChangeFrameNotification notification? – rmaddy Dec 14 '17 at 07:21
  • I'm trying to figure out how to get the height of the keyboard when it appears and adjust my view, then reset my view when it disappears. This is the idea I was going for.. – erroneous switch Dec 14 '17 at 09:06
  • `NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardMovements(notification:)), name: .UIKeyboardWillChangeFrame, object: nil)` – erroneous switch Dec 14 '17 at 09:10
  • `@objc func handleKeyboardMovements(notification: Notification) { // need to get height of keyboard when it opens // scroll my view up and down as keyboard shows and hides }` – erroneous switch Dec 14 '17 at 09:10
  • @user8244799 Check this: https://stackoverflow.com/questions/26070242/move-view-with-keyboard-using-swift – Dharmesh Kheni Dec 14 '17 at 09:47
  • 1
    @user8244799 Don't post code in comments. Edit your question and update with all relevant information. – rmaddy Dec 14 '17 at 15:04

0 Answers0