我有一个表格视图控制器,其中一行中有 5 个文本框,当我们单击添加按钮时,这些文本框添加了空值。
我正在尝试通过 Core Data 将数据保存在数据库中。
我的问题是,当我单击文本框并完成输入值并通过触摸屏尝试输入数据时,光标会转到另一个文本框,但在我按下 Return 之前不允许我输入文本键盘上的键。
这是我对文本框的编码:
-(void)textFieldDidEndEditing:(UITextField *)textField
{
row1=textField.tag;
NSLog(@"Row is %d",row1);
path = [NSIndexPath indexPathForRow:row1 inSection:0];
Input_Details *inputDetailsObject1=[self.fetchedResultsController objectAtIndexPath:path];
/*
Update the Input Values from the values in the text fields.
*/
EditingTableViewCell *cell;
cell = (EditingTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row1 inSection:0]];
inputDetailsObject1.mh_Up= cell.cell_MH_up.text;
inputDetailsObject1.mh_down=cell.cell_MH_dn.text;
inputDetailsObject1.sewer_No=[NSNumber numberWithInt:[cell.cell_Sewer_No.text intValue]];
inputDetailsObject1.mhup_gl=[NSNumber numberWithFloat:[cell.cell_gl_MHUP.text floatValue]];
inputDetailsObject1.mhdn_gl=[NSNumber numberWithFloat:[cell.cell_gl_MHDN.text floatValue]];
inputDetailsObject1.pop_Ln=[NSNumber numberWithInt:[cell.cell_Line_pop.text intValue]];
inputDetailsObject1.sew_len=[NSNumber numberWithFloat:[cell.cell_Sewer_len.text floatValue]];
[self saveContext];
[textField resignFirstResponder];
NSLog(@"Saving the MH_up value %@ is saved in save at index path %d",inputDetailsObject1.mh_Up,row1);
}
-(void)saveContext
{
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSError *error = nil;
if (![context save:&error])
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
这是表格视图和文本框的图片。