Reload a UITable on the fly when editing a UITextField inside one of the cells
- by Saze
I have a UITable containing some customs UITableCells. Those cells contain a few UILabels and a UITextField. The datasource of the table comes from a main controller's property. (This controller is also the delegate and the dataSource for the table).
Here's a simplified screenshot of the UI:
Now, I need to update "on the fly" the content of all the UILabels when the user edits one of the UITextFields.
To do so, at the I am listening to the "Editing Changed" event at the UITextField level. This triggers the following action:
- (IBAction) editChangeHandler: (id) sender {
MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[[delegate.viewController.myDataSourceArray objectAtIndex:self.rowIndex] setANumber: [theTextField.text intValue]];
[delegate.viewController reloadRows];
}
The reloadRows method in the viewController is as such:
- (void) reloadRows {
NSLog(@"called reloadRows");
//perform some calculations on the data source objects here...
[theUITable reloadData];
}
My problem here is that whenever the user changes the value in the field, the reloadRows method is successfully called, so is apparently the reloadData but it also causes the keyboard to be dismissed.
So in the end, the user can only touch one key when editing the TextField before the keyboard is dismissed and the table reloaded.
Does anybody knows a solution to this or have experienced the same issue?