LoginSignup
0
1

More than 5 years have passed since last update.

TextFieldのキーボードを表示させない方法

Posted at

はじめに

TextFieldの入力をbuttonなどで行いたいと思った時に、標準キーボードが邪魔なので表示させない方法を調べました。

方法1

func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
    return false
}

でも、この方法だとタッチイベントが使用できなくなっちゃいます。

方法2

let textField = UITextField()
let dummyView = UIView()

textField.inputView = dummyView

TextFieldのinputViewをダミーのViewに設定すればタッチイベントも使用できる状態で、標準キーボードが見えなくなります。

0
1
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
0
1