我添加了观察者,以便我可以将textFields移到键盘上方。
它在所有设备上工作正常,但在模拟器iPhone 4S(iOS 9)中运行时不会调用keyboardWillAppear
函数。
当我和#34;连接硬件键盘"
keyboardWillHide
而不是keyboardWillShow
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector:"keyboardWillAppear:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:"keyboardWillDisappear:", name: UIKeyboardWillHideNotification, object: nil)
}
func keyboardWillAppear(notification: NSNotification){
// This is not called on simulator iPhone 4S(iOS 9.0)
}
func keyboardWillDisappear(notification: NSNotification){
// This is called
}
我真的无法理解这种行为。有人可以解释导致这种情况的内部功能。