如何处理名称为“的键盘按钮”;“完成”;在ios中
现在我有了一个文本字段 当我输入一些单词时,键盘就会出现 当我按下键盘“完成”时,键盘将消失。(我已经完成了这个功能) 但是接下来呢, 我想在用户按下“完成”按钮时使用core data framework插入数据 那么,如何解决这个问题呢 我知道如何使用核心数据插入数据,因此您无需告诉我如何插入数据 我正在使用此代码来删除键盘如何处理名称为“的键盘按钮”;“完成”;在ios中,ios,button,keyboard,Ios,Button,Keyboard,现在我有了一个文本字段 当我输入一些单词时,键盘就会出现 当我按下键盘“完成”时,键盘将消失。(我已经完成了这个功能) 但是接下来呢, 我想在用户按下“完成”按钮时使用core data framework插入数据 那么,如何解决这个问题呢 我知道如何使用核心数据插入数据,因此您无需告诉我如何插入数据 我正在使用此代码来删除键盘 -(BOOL)textFieldShouldReturn:(UITextField *)theTextField { [txtName resignFirstRes
-(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;
}
谢谢,它可以工作。但是stackoverflow.com不能让我浏览新页面