我正在使用socket.io创建聊天应用程序,但无法处理用户输入通知,我不知道我在哪里做错了,我显示了代码
代码:
从这里我发布我的通知
func listenForOtherMessages() {
socket.on("userTypingUpdate") { (dataArray, socketAck) -> Void in
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "userTypingNotification"), object: dataArray[0] as? [String: AnyObject])
}
}
从这里我要发送通知
@objc func handleKeyboardDidShowNotification(notification: NSNotification) {
if let userInfo = notification.userInfo {
if let keyboardFrame = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
conBottomEditor.constant = keyboardFrame.size.height
view.layoutIfNeeded()
}
}
}
最后一个是我放置选择器,但是我的通知已成功发布,但仍然可以收到
let notificationCenter4 = NotificationCenter.default
notificationCenter4.addObserver(self, selector: #selector(handleKeyboardDidShowNotification(notification:)), name:NSNotification.Name(rawValue: "userTypingNotification"), object: nil)