未调用UIKeyboardWillShowNotification选择器但调用了HideNotification

时间:2015-11-08 14:06:30

标签: ios swift2 nsnotificationcenter

我添加了观察者,以便我可以将textFields移到键盘上方。 它在所有设备上工作正常,但在模拟器iPhone 4S(iOS 9)中运行时不会调用keyboardWillAppear函数。 当我和#34;连接硬件键盘"

时会发生这种情况 正在调用

keyboardWillHide而不是keyboardWillShow

keyboard

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
}

我真的无法理解这种行为。有人可以解释导致这种情况的内部功能。

0 个答案:

没有答案