1

I need to show the keyboard automatically when I will go to a particular View controller. Let take an example I have two view controller named "A" and "B". I have a text field present in the "B" view controller. When I am navigating from "A" to "B", I need to show the keyboard automatically. How to do it?

1
  • 2
    Make the textfield in B firstresponder in B's viewDidAppear Method. Resign firstResponder on ViewWillDisappear or something. Commented Oct 10, 2019 at 7:25

2 Answers 2

1

in B view controller

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    textField.becomeFirstResponder()
}
Sign up to request clarification or add additional context in comments.

Comments

0

Type it in your B ViewController

    override func viewDidLoad() {
        super.viewDidLoad()

        self.yourTextFieldName.delegate = self
        self.showKeyBoard()
    }

    func showKeyBoard(){
        self.yourTextFieldName.becomeFirstResponder()
    }

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.