iPhone how to get UITextField's text while typing?

后端 未结 7 2058
别那么骄傲
别那么骄傲 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:21

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
            if textField == yourTextFieldOutletName
            {
               if yourTextFieldOutletName.isEmpty == false
               {
                 youtlabelname.text = yourTextFieldOutletName.text!
                }
    
    
            }
    
            return true
    
        }
    
    func textViewDidEndEditing(_ textView: UITextView) {
           if textField == yourTextFieldOutletName
                {
                   if yourTextFieldOutletName.isEmpty == false
                   {
                     youtlabelname.text = yourTextFieldOutletName.text!
                    }
    
    
                } 
        }
    

提交回复
热议问题