Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the firstresponder?

I have a view built through IB, there's a text view and and button on it. When the view shows up I would like to have the keyboard to be already displayed.

I tried to set the first responder in the didViewLoad but that didn't work.

I do have an IBOutlet that is connected to the textView and related accessor.

like image 318
amok Avatar asked Sep 14 '09 16:09

amok


People also ask

What is becomeFirstResponder?

Notifies the receiver that it's about to become first responder in its NSWindow .

What is becomeFirstResponder in IOS?

becomeFirstResponder()Asks UIKit to make this object the first responder in its window.

What is first responder in Xcode?

The first responder is usually the first object in a responder chain to receive an event or action message. In most cases, the first responder is a view object that the user selects or activates with the mouse or keyboard.

What is resign first responder Swift?

If you want that text control to stop waiting for input – which in turn dismisses the keyboard – you should call its resignFirstResponder() method, which passes the first responder baton to the next waiting component.


1 Answers

Looks like you may have accidentally misspelled the method name didViewLoad instead of viewDidLoad. All you should need there (assuming your IBOutlet is connected in IB) is the following:

[textView becomeFirstResponder];
like image 89
jlehr Avatar answered Oct 24 '22 18:10

jlehr