0

I have a Table view controller with 5 textboxes in a row which are added with null values when we click on add button.

I am trying to save the data in a database via Core Data.

My problem is that when I click in the text box and finish putting the value and via a touch screen when i am trying to put the data the cursor goes to the other text box but do not allow me to enter text until I press the Return key on the keyboard.

Here is my coding for the text box:

-(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();
    }


}

Here is a picture of the table view and text boxes.

1 Answer 1

0

didEndEditing means you pressed the return key or moved the responder to another object.

If you want to move to the next text box by some other mechanism then you need to implement some other delegate method. For example, this method textField:shouldChangeCharactersInRange:replacementString: fires every time you change a characters in a textfield. You can use it to change the responder based on the input for example.

To tell the next text box to become the first responder you call [mySecondField becomeFirstResponder].

hope this helps.

Sign up to request clarification or add additional context in comments.

9 Comments

Hi thanks for the reply...i am able to move to another text box via a touch screen but not able to feed the values...sometimes i can but sometimes i cannot.
can you be more elaborate? what happens exactly? why cant you feed the values?
we put the cursor to the other text box it blinks the cursor then dont allow me to enter values to the text box..( we can say that it just get hanged up) and when i press done btn or keyboard down btn then it allows me to put the text. but its not happening all the time..sometimes i am able to put the values..or i can say i put values to 2 to 3 text box simultaneously then this problem arise...
try and remove [textField resignFirstResponder] from textFieldDidEndEditing:. it could be conflicting.
Hi if i try to move the cursor from one text box to another text box, the cursor blinks one time but does not really move to that text box as i am unable to feed any values in that text box. Please note that in random cursor moves to some of the text box and you can also feed the values to that text box but it is not happening all the time.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.