我在堆栈溢出上搜索了很多,但根据他们的解决方案,我的程序与提到的相同,但仍然无法正常工作。
func subscribeToKeyboardNotifications() {
NotificationCenter.default.addObserver(self, selector:Selector(("keyboardWillShow:")), name:NSNotification.Name.UIKeyboardWillShow, object: nil)
}
func keyboardWillShow(notification:NSNotification) {
view.frame.origin.y -= getKeyboardHeight(notification: notification)
}