Пользовательская метка-заполнитель Swift UITextView не исчезает должным образом - PullRequest
0 голосов
/ 25 ноября 2018

Исчезать метки-заполнители других UITextView

Существует 3 UITextViews и 3 метки-заполнителя (сгенерировано программно) Когда я коснулся или изменил 1-й UITextView или 2-й UITextView, исчезла только третья метка-заполнитель.Есть ли способ решить эту проблему?

for idx in 0..<kNumberOfDiaryCard {
  let x = CGFloat(0)
  let y = CGFloat(idx % 3) * (diaryCardHeight + pad)

  // 1 DiaryCards
  diaryCardView = UIView()
  diaryCardView.frame = CGRect(x: x, y: y, width: diaryCardWidth, height: diaryCardHeight)
  diaryCardBaseView.addSubview(diaryCardView)

  // 2 mood color view of DiaryCards
  moodColorView = UIView()
  moodColorView.frame = CGRect(x: 0, y: 0, width: moodColorViewWidth, height: moodColorViewTotalHeight)
  diaryCardView.addSubview(moodColorView)

  // 3 text view of DiaryCards
  textView = UITextView()
  textView.delegate = self
  textView.frame = CGRect(x: xx, y: yy, width: textViewWidth, height: textViewHeight)
  textView.tag = idx
  diaryCardView.addSubview(textView)

  // 4 placeholder label
  placeholderLabel = UILabel()
  placeholderLabel.frame = CGRect(x: xxx, y: yyy, width: placeholderLabelWidth, height: placeholderLabelHeight)
  placeholderLabel.tag = idx

  placeholderLabel.text = DiaryMainView.init().placeHolderTxt[idx]
  diaryCardView.addSubview(placeholderLabel)
}




func textViewDidBeginEditing(_ textView: UITextView) {
  textView.becomeFirstResponder()
}

func textViewDidChange(_ textView: UITextView) {
  placeholderLabel?.isHidden = !textView.text.isEmpty
}

func textViewDidEndEditing(_ textView: UITextView) {
  textView.resignFirstResponder()
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...