I have a plain style table, with multiple sections.
Symptoms: when the table is first loaded, each cell has it's separator as normal, except the last cell in each section (that is "before" a header). However, when there is scrolling, on some cells the separator appears. Also, if a cell is selected, then deselected, the separator appears.
Printing the view hierarchy shows, that on clean start, the separator view of the last cell in each section is hidden, so I would assume that would be the normal behavior:
<_UITableViewCellSeparatorView: 0x145b1990;
frame = (0 47.5; 320 0.5);
hidden = YES;
layer = <CALayer: 0x145b2950>>
On scrolling sometimes; and by selecting the cell; this hidden property gets removed, and so the separator appears.
First assumption was I was doing something wrong; but this happens with the most basic hello world application too:
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 4;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return 2;
}
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section {
return @"test";
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *reuseIdentifier = @"TestCell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:reuseIdentifier];
return cell;
}
Screens (left: after start; right: after selecting a cell):
Is this a bug on Apple's side, or am I missing something? Also, for example, in the iOS Contacts application the separator is never hidden above a section header...
**Update: **
Was able to reproduce this in stock Music app: e.g. Songs tab, no spearator. Select then deselect first cell of any section; separator appears.
Extra info: iOS 7.1
Since this is an iOS 7.1 bug, as a workaround I would suggest hiding the built-in separator and showing one of your own at the bottom of each cell.
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *reuseIdentifier = @"TestCell";
XXYourCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
cell.customSeparatorView.hidden = (indexPath.row == ([self numberOfRowsInSection:indexPath.section] - 1));
return cell;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With