I have an application with dynamic data loaded into a tableview. When there is only one item (thus only one cell). To make sure that the UITableViewCellSeperator is not showing up for this one item I am using this code:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return 0.01f;
}
This works as expected and here is what my cell looks like:
As you can see this works as expected and there is no cell separator.
When I select the cell and display my detail view and then hit the back button, the cell adds a separator for some reason. Here is what the cell looks like once I navigate back in the stack:
You will notice that the separator is now wider than the standard separator. If my tableview has more than one cell in it, the last cell in the tableview will behave this same way.
When I remove the above method, the issue is fixed, but now my tableview has a TON of extra separators for empty cells. Is there a better solution?
Here is my cellForRowAtIndexPath method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"searchCell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.backgroundColor = [UIColor PFBlack];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.font = [MuseoSans font500WithSize:16.0f];
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.text = @"Current Location";
return cell;
}
Any idea what is causing the issue? Or am I doing something wrong? Thanks!