Swift3.0 监听UITextView文字改变

来源:互联网 发布:sql删除一个月前数据 编辑:程序博客网 时间:2024/05/22 07:06

//创建一个通知

    NotificationCenter.default.addObserver(self, selector:#selector(你的viewcontroller.textViewChange), name: NSNotification.Name.UITextViewTextDidChange, object:nil)

//移除通知

⚠️要在class里面写这个方法

    deinit {

        NotificationCenter.default.removeObserver(self)

    }

//对应方法

    func textViewChange()  {

print("textView文字改变 :\(你的tcomposeTextView.text)")

    }



0 0