I'm trying to update this code to swift 3:
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name: UIKeyboardWillHideNotification, object: nil)`
So far, I've just tried the auto corrections given by the compiler. This results in code like this:
let notificationCenter = NotificationCenter.default()
notificationCenter.addObserver(self, selector: Selector(("keyboardWillShow:")), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
notificationCenter.addObserver(self, selector: Selector(("keyboardWillHide:")), name: NSNotification.Name.UIKeyboardWillHide, object: nil)`
Unfortunately, that doesn't take me far, resulting in additional errors.
Has anyone solved this please?
Please note that I'm just trying how to write the notifications. I'm not (yet) trying to fix the notification functions.. Thanks
Swift 5.1 + Combine + SwiftUI
Here is the best solution that works for me as far (used from "Lets Build That App" YouTube channel)
Swift 4
You Can Also Get Keyboard Info Uisng Below Code Inside These Methods.