swift textfield 和 textview 實時獲取 輸入內容


textfield :

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {

            let fullStr = (textField.text! as NSString).replacingCharacters(in: range, with: string)
            delegate?.changeTextFieldText(tfTag: textField.tag, text: fullStr)

        return true
    }

  

textview : 一樣

    func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {

        let fullStr = (textField.text! as NSString).replacingCharacters(in: range, with: string)
        return true
    }

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM