use*_*083 6 cocoa objective-c textfield
我有3个文本字段(用户名,密码,确认密码).当表单加载时,我希望光标在首次显示表单时在文本域用户名中开始.请给我一些建议.预先感谢.
Ale*_*der 28
[usernameTextField becomeFirstResponder];
这应该为您提供所需的结果.如果您想了解有关该机制的更多信息,可以在此处阅读响应者链.
编辑:
我的坏,我以为你的意思是UITextField(Cocoa Touch).
使用NSWindow makeFirstResponder:方法而不是此方法将对象作为第一个响应者.永远不要直接调用此方法.
[window makeFirstResponder:usernameTextField];
Run Code Online (Sandbox Code Playgroud)