How do I set the firstresponder?

不羁岁月 提交于 2019-12-03 22:42:48

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];

I know this is tagged as cocoa-touch but this is highly ranked in Google and I ran into trouble with using -becomeFirstResponder on OS X; it did nothing. From the NSResponder documentation,

Use the NSWindow makeFirstResponder: method, not this method, to make an object the first responder. Never invoke this method directly.

So on OS X use,

[[myView window] makeFirstResponder:myView];

For Swift

textView.becomeFirstResponder()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!