4

Is it possible to prevent UITableViewCellSelectionStyleNone from removing a cell separator?

I have a custom expandable UITableViewCell and this is what happens when I click a cell:

Separator between King’s Meadow and University East Entrance missing

If you look closely, there is no separator between King's Meadow and University East Entrance.

When I use this, it actually makes the separator visible, but there's a delay as to when the line separator shows:

(void)layoutSubviews {
    [super layoutSubviews];

    for (UIView *subview in self.contentView.superview.subviews) {
        if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
            subview.hidden = NO;
        }
    }
}

Is there a better approach for this?

ipalibowhyte
  • 1,553
  • 2
  • 22
  • 34
  • Do "King's Meadow" and "University ..." belong to different cells? Is the gray area the expanded area of "University ..."? If you're using the simulator, have you zoomed to the maximum to check if the missing line is actually a visual artifact due to low resolution? – keeshux Sep 01 '14 at 21:36
  • no, they do not belong in the same cell, they are in there respective cells, yes they gray area is the expanded area and yes i have zoomed in :) and i still don't see anything – ipalibowhyte Sep 01 '14 at 21:53
  • 1
    A little research found this to be an iOS 7 bug, several workarounds are described [here](http://stackoverflow.com/questions/19212476/uitableview-separator-line-disappears-when-selecting-cells-in-ios7). – keeshux Sep 01 '14 at 22:03
  • 1
    Nice, would you share your personal solution as an answer? Other users would surely appreciate. – keeshux Sep 01 '14 at 22:13

1 Answers1

1

This fixed my problem:

In the didSelectRowAtIndexPath method, I used the following:

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

}

Worked like magic!

ipalibowhyte
  • 1,553
  • 2
  • 22
  • 34