カスタム キーボード拡張機能を作成しています。キーボードの非表示/表示通知のオブザーバーとして登録していますが、ブレークポイントがヒットせず、ログ ステートメントが印刷されません。UIInputViewController サブクラス内の NSNotifications で何か違うことがありますか、それとも何か間違っていますか?
import UIKit
class KeyboardViewController: UIInputViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Perform custom UI setup here
let keysView:UIView = NSBundle.mainBundle().loadNibNamed("KeyboardView", owner: self, options:nil)[0] as UIView
keysView.frame = self.inputView.frame
keysView.setTranslatesAutoresizingMaskIntoConstraints(false)
self.inputView.addSubview(keysView)
self.inputView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[keysView]|", options: nil, metrics: nil, views:["keysView":keysView]))
self.inputView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[keysView]|", options: nil, metrics: nil, views:["keysView":keysView]))
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Listen for changes to keyboard visibility so that we can adjust the view accordingly.
let notificationCenter = NSNotificationCenter.defaultCenter()
notificationCenter.addObserver(self, selector: "handleKeyboardWillShowNotification:", name: UIKeyboardWillShowNotification, object: nil)
notificationCenter.addObserver(self, selector: "handleKeyboardWillHideNotification:", name: UIKeyboardWillHideNotification, object: nil)
}
override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
let notificationCenter = NSNotificationCenter.defaultCenter()
notificationCenter.removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
notificationCenter.removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
}
func handleKeyboardWillHideNotification(notification: NSNotification) {
NSLog("keyboardWillHide")
}
func handleKeyboardWillShowNotification(notification: NSNotification) {
NSLog("keyboardWillShow")
}
}