在ios中如何处理名称为“ done”的键盘按钮

|| 现在我有一个textField。 然后输入一些字词,键盘就会出现。 当我按键盘“完成”时,键盘将消失。 (我已完成此功能) 但是接下来 我想在用户按下按钮“完成”时使用核心数据框架插入数据 那么,如何解决这个问题呢? 我知道如何使用核心数据插入数据,因此您无需告诉我如何插入数据。 我正在使用此代码来消失键盘。
-(BOOL)textFieldShouldReturn:(UITextField *)theTextField {
  [txtName resignFirstResponder];
  return YES;
}
谢谢大家     
已邀请:
在示例代码中,我有3个UITextField。在我们到达最后一个字段后,您可以处理您的更新
// I the tag property to indicate which field I am on during runtime
enum {
    Line1Tag = 50,
    Line2Tag,
    Line3Tag
};

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    // The user has pressed the \"Return Key\"
    // Which I have set to \"Next\" for first two lines
    // and \"Done\" for the last line, so jump to the next text field
    NSLog(@\"\\\"Return\\\" key pressed.\");

    // based on which text field we are in jump to the next
    if (textField.tag == Line3Tag)
        // We have reach the last line so hide keyboard
        [textField resignFirstResponder];

        // this is where you can perform Core Data updates if you like

    else {
        int nextTag = textField.tag + 1;
        UIView *nextField = [self.view viewWithTag:nextTag];
        [nextField becomeFirstResponder];

        // Once the next text field is the first responder
        // I need to make sure the user can see it
        [self makeActiveTextFieldVisible];
    }
    return NO;
}
    

要回复问题请先登录注册