iPhone how to get UITextField's text while typing?

后端 未结 7 1987
别那么骄傲
别那么骄傲 2020-12-12 21:54

I\'m trying to show changes made to a UITextField on a separate UILabel. Is there a way to capture full text of the UITextField after

相关标签:
7条回答
  • 2020-12-12 22:31

    Swift 3.0+: This worked very nicely for me.

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        self.yourLabel.text = "\(textField.text ?? "")\(string)"
        return true
    }
    
    0 讨论(0)
提交回复
热议问题