IOS: action with enter key of iPad KeyBoard

后端 未结 4 497
不思量自难忘°
不思量自难忘° 2021-02-06 22:36

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 creat

4条回答
  •  情歌与酒
    2021-02-06 22:56

    You can do that by implementing the UITextFieldDelegate protocol in your controller. For instance you could do something like:

    - (BOOL)textFieldShouldReturn:(UITextField *)textField {
        if (textField == theFirstTextField && [textField.text isEqualToString:@"Hello"]) {
            theSecondTextField.text = @"World";
        }
        return YES;
    }
    

提交回复
热议问题