Buttonを押したActionで、TextFieldにフォーカスを当てて、キーボードを出したい。
textFieldにフォーカスを当てるにはbecomeFirstResponder()を使う。
@IBAction func startDateButton(_ sender: Any) {
startTextField.becomeFirstResponder()
}
投稿日:
Buttonを押したActionで、TextFieldにフォーカスを当てて、キーボードを出したい。
textFieldにフォーカスを当てるにはbecomeFirstResponder()を使う。
@IBAction func startDateButton(_ sender: Any) {
startTextField.becomeFirstResponder()
}
執筆者:swift
関連記事
レガシータイトルで綺麗な角丸四角形を作りたい。 角丸長方形(可変)ツールで作ると角が歪む 角丸長方形を作成し、右の「フィレットサイズ」で角を調整できる。 ただし、角が歪んでしまう。(画像の下の長方形の …
UIViewをのせると、その下にあるボタンやcollectionViewのタッチイベントを感知しなくなる。 UIViewのタッチイベントを透過することで、下のボタンなどが使えるようになる。 Story …
VCからNavigationControllerへの遷移で値を渡す
ViewControllerからNavigationControllerへの画面遷移で値を渡す方法。 通常の画面遷移による値渡しと少し異なるので注意。 参考:【Swift】NavigationCont …
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoa …