IOS: action with enter key of iPad KeyBoard

后端 未结 4 499
不思量自难忘°
不思量自难忘° 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 23:00

    This is roughly what you'd do. Tweaking to condition around device-type (if you truly want iPad only):

    #pragma mark - UITextField Delegate
    
    - (BOOL)textFieldShouldReturn:(UITextField *)textField 
    {
        if (textField == self.firstTextField && [textField.text isEqualToString:@"Hello"]) {
            self.secondTextField.text = @"World";
        }
        return YES;
    }
    

提交回复
热议问题