I hope someone can help…
I’ve setup a static UITableView Controller with four sections. The top two sections are for inputting data. The third section has 1 cell and contains a save button.
The final section has 6 cells and I want to be able to populate these six cells with the data from the first two sections, in the long run anyway…
So i tried to a small example, but it’s not working. The console returns the following error:
UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:’
* First throw call stack:
Here’s an example:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
NSIndexPath *EditRow = [NSIndexPath indexPathForRow:1 inSection:4];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:EditRow];
NSString *test = @"Test";
cell.textLabel.text = test;
NSLog(@"Index Path: %d", indexPath.row);
NSLog(@"Cell ID:, %@", CellIdentifier);
return cell;
}
So my question comes down to.. How do I update a specific cell in a specific section?
Thanks
When I implement static cells, I delete the
cellForRowAtIndexPath,numberOfSectionsInTableView, andnumberOfRowsInSectionmethods from the genericUIViewControllerstub that Xcode generates; these seem to be necessary only when you’re dealing with dynamic cells.Then, by control-dragging in the storyboard, I create named outlets for all UI elements in the cells that need to be set programmatically; in my case, these are usually
UILabels. In theviewDidLoadmethod of the controller, I set the appropriate initial values of these outlets, for example:Once you’ve got this wired up, you can change any of the values at will.
I hope that this works for you. I’d be happy to learn from anyone who has a better (more appropriate?) way of doing this.