你如何改变UIControl重点关注iPhone?

And*_*ndy 7 cocoa-touch

我想做一些我认为很简单的事情.

我有一个带有两个UITextFields的表单.我在第一个使用UIReturnKeyNext样式.这个想法是当用户填写第一个字段时,他们单击Next并将它们转换到下一个UITextField.我已经看到其他应用程序执行此操作并且它运行良好.但我无法弄清楚如何将焦点设置到下一个字段.

Bra*_*Guy 9

简单.将becomeFirstResponder消息发送到您的其他文本字段.当另一个文本字段接受第一响应者状态时,它将从键盘接收信息.

例如:

//called when the next button is pressed
//Assume textField1, 2, and 3 are instances of UITextField
-(IBAction) nextPressed: (id) sender {
      if ([textField1 isFirstResponder]) {
         [textField2 becomeFirstResponder];
      }
      if ([textField2 isFirstResponder]) {
         [textField3 becomeFirstResponder];
      }

}
Run Code Online (Sandbox Code Playgroud)