Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何以编程方式将焦点分配给视图中的特定 UITextField?我有几个字段并且在视图显示中,我想将光标放在特定字段上,而不是顶部的第一个字段。
尝试这样做viewWillAppear:
viewWillAppear:
[desiredField becomeFirstResponder];
通过使该字段成为第一响应者,它具有焦点并且将显示键盘。
将视图的第一响应者设置为文本字段。这可以在 IB 中完成。
迅速:
desiredField.becomeFirstResponder()