8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swift4でUITextViewのリアルタイム文字数カウントを実装

Posted at

手順は3つ

UITextViewDelegateを継承し

ViewController: UIViewController, UITextViewDelegate {

リアルタイムで文字数カウントをしたいUITextViewにdelegate設定

commentTextView.delegate = self

メソッドtextViewDidChange内に記述

func textViewDidChange(_ textView: UITextView) {
        let commentNum = commentTextView.text.count
        commentNumLabel.text = String(commentNum)
    }
8
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?