如何更改UIControl专注于iPhone? [英] How do you change the UIControl with focus on iPhone?

查看:100
本文介绍了如何更改UIControl专注于iPhone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to do something I thought would be simple.

我有一个带有两个UITextField的表单。我在第一个使用UIReturnKeyNext样式。这个想法是,当用户填写第一个字段时,他们单击下一步,我将它们转换到下一个UITextField。我看过其他应用程序这样做,它的工作原理很好。但我不知道如何将焦点设置到下一个字段。

I have a form with two UITextFields on it. I am using the UIReturnKeyNext style on the first. The idea is that when the user fills in the first field, they click Next and I transition them to the next UITextField. I've seen other apps that do this and it works really well. But I cannot figure out how to set the focus to the next field.

推荐答案

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

Simple. send a becomeFirstResponder message to your other textfield. When the other textfield accepts first responder status, it will receive the information from the keyboard.

例如:

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

}

这篇关于如何更改UIControl专注于iPhone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆