用户类型通知未处理时出现的问题

时间:2018-09-08 11:02:24

标签: ios swift socket.io nsnotificationcenter

我正在使用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)

0 个答案:

没有答案