【发布时间】:2017-08-23 08:42:29
【问题描述】:
在尝试使用新的 Swift NotificationCenter 时,我试图将观察者对象创建为属性(与将观察者分配给自身的经典 Obj-C 模式相反):
private let keyboardWillShowObserver = {
return NotificationCenter.default.addObserver(forName: .UIKeyboardWillShow, object: nil, queue: nil, using: self.keyboardWillShow(_:))
}()
private func keyboardWillShow(_ notification: Notification) {
bottomVerticalSpaceConstraint.constant = 400
}
问题是我收到以下错误消息,即使我有同一个类的成员函数部分:
'(NSObject) -> () -> MyAwesomeViewController' 类型的值没有成员 'keyboardWillShow'
【问题讨论】: