i have this that works:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Item *objItem = [[self fetchedResultsController] objectAtIndexPath:indexPath];
CustomCell *cell = nil;
cell = [self.tableView dequeueReusableCellWithIdentifier:identifierLONG];
[self configureCell:cell atIndexPath:indexPath tableView:tableView];
}
And i want to do something like this:
- (void)configureCell:(TimelineTextoFotoCell *)cell atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView{
Item *objItem = [[self fetchedResultsController] objectAtIndexPath:indexPath];
cell.txtNota.text = objItem.nota;
if ([cell.txtNota.text sizeWithFont:cell.txtNota.font constrainedToSize:CGSizeMake(cell.txtNota.frame.size.width, 1000.f)].height/cell.txtNota.font.pointSize < 2.0) {
cell = [tableView dequeueReusableCellWithIdentifier:identifierSHORT];
} else {
//should remain dequeueReusableCellWithIdentifier:identifierLONG....
}
//setup cell the same, for both cases.
}
It doesnt work. The cell always uses the dequeueReusableCellWithIdentifier:identifierLONG, and i checked the line cell = [tableView dequeueReusableCellWithIdentifier:identifierSHORT]; gets executed. I need to change the identifier based on the fetched objectAtIndexPath:indexPath
From what I can see, you always request a cell with identifierLONG in
cellForRowAtIndexPath. Then you pass that over toconfigureCell, where you optionally try to replace that cell with one with identifierSHORT. I guess that might be too late because you already dequeued one with identifierLONG. To be honest, I never tried something like that, so I can’t tell for sure whether that’s the cause of your problem.Did you already try something like this in
cellForRowAtIndexPath: