aakpro
aakpro

Reputation: 1578

UITableView selected cell separator not shown in iOS 7.1

I have a very strange problem. Separator line of selected cell in UITableView has not shown in iOS 7. As following Picture:

enter image description here

So I used the following codes:

-(void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
    // fix for separators bug in iOS 7
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}

-(void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath {
    // fix for separators bug in iOS 7
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}

It solved problem when I used xCode 5 on iOS7.

But as soon as I updated to xCode 5.1 and compiled my app on iOS 7.1, the problem occurred again and none of tricks worked this time. I used:

  1. cell.clipsToBounds = YES;

2.[tableView reloadRowsAtIndexPaths:indexPath withRowAnimation:UITableViewRowAnimationNone];

  1. Removed my previous code.

  2. Tried several separator styles.

and some other tricks. Unfortunately none of them worked this time.

What would be problem? And how can I solve it?

Upvotes: 2

Views: 1042

Answers (1)

aakpro
aakpro

Reputation: 1578

I finally typed following lines of code:

[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
UIView * lineAfterCell = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.size.height + 1, self.view.frame.size.width, .5)];
[lineAfterCell setBackgroundColor:[UIColor lightGrayColor]];
[cell addSubview:lineAfterCell];

And it worked perfectly.

Upvotes: 1

Related Questions