0

enter image description hereUITextView는 대리자 메서드

나는 그것의 텍스트 색상을 변경하여 내 UITextView에 반응하는 내 UILabel의를 만드는 데 문제가 응답하지 않습니다.

그래서 내 UITextView에 250 단어가 넘으면 내 UILabel이 빨간색으로 바뀌어야합니다. 그러나 그것은 웬일인지 그것을하지 않는다.

// class NewAppViewController: UIViewController, UITextViewDelegate... 
    func textViewDidChange(_ textView: UITextView) { 
      let characterCounts = commentTextField.text.characters.count 
      wordCountLabel.text = String(250 - characterCounts) 
      if (250 - characterCounts) < 0 { 
       self.wordCountLabel.textColor = UIColor.red 
       sendButton.isEnabled = false 
      } else { 
       sendButton.isEnabled = true 
      } 
    } 
+1

uitextview에 위임자를 지정 했습니까? – Rafeek

+0

답변을 찾은 것 같아요 ... – Giraffe

+0

위임자를 추가하지 못했습니다. – Arti

답변

0

나는 부주의했다. 실수로 UITextField를 사용했습니다. 이제 UITextView로 돌아 가면 모든 것이 잘 동작합니다.

다음은 사진입니다.

enter image description here

+0

답변을 수락 된 것으로 표시하십시오. – mattsson