cellForRowAtIndexPath called when table cell is clicked on to edit [closed]
-
16-09-2019 - |
Question
When a table is created, cellForRowAtIndexPath
is called to populate the cells. Previously when a cell was clicked on to edit, cellForRowAtIndexPath
wasn't called, and the cell could have text typed into it using:
#pragma mark Text Field Delegate Methods
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
self.textFieldBeingEdited = textField;
}
Now when I click on cells that are below the cell with row = 4, which is where the top of the keyboard is, cellForRowAtIndexPath
is called with a row greater than the total number of rows causing a crash. When I click on cells 0 to 4, I can edit the cells and cellForRowAtIndexPath isn't called. cellForRowAtIndexPath wasn't called previously for clicking on any of the cells. I changed something that is causing this, but can't figure out what it is.
Does anyone know what can cause cellForRowAtIndexPath to be called when clicking on a cell to edit it? It almost appears like it thinks a new table is being created.
Solution 2
I figured out what the problem was. I had specified one more row in the table than actually existed.
OTHER TIPS
If you have this line:
[myTable reloadData];
Anywhere in the code, it will call CellForRowAtIndexPath again.