IOS:用iPad KeyBoard的回车键动作

IOS:用iPad KeyBoard的回车键动作

问题描述:

我有两个文本字段,在第一个文本字段中我写Hello,当我按下进入iPad键盘时,我希望在第二个文本字段中显示World;如何在我的应用程序中使用enter来创建操作?

I have two textfield, in first textfield I write "Hello" and when I push enter in iPad keyboard, I want that in second textfield appear "World"; How can I use enter to create an action in my application?

您通常会将视图控制器指定为文本字段的委托然后实现 textFieldShouldReturn:方法,例如:

You would typically assign your view controller as the text field's delegate and then implement the textFieldShouldReturn: method, e.g.:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    otherTextField.text = @"World"
    return YES;
}