Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCells bottom edge flickering when app enters foreground

I've build an app which contains an UITableView with a bunch of cells. Inside the cells I've got a view, which fill the whole cell. I've configured the tableview like this:

tableView.separatorStyle = .none
tableView.backgroundColor = UIColor(red: 24/255.0, green: 34/255.0, blue: 41/255.0, alpha: 100)
tableView.separatorColor = UIColor(red: 26/255.0, green: 34/255.0, blue: 40/255.0, alpha: 100)

Whenever the app enters the foreground, I got those little lines flickering for 0.5 seconds or so. To be clear, I don't want those.

enter image description here

And this is how it looks like when the app fully entered the foreground, and how it is supposed to look like:

enter image description here

Any ideas how to get rid of them?

EDIT 1:

I'm starting to doubt that the flickering is related to the separators, because it is only happening between cells in a section, not between the section-cell and the first cell in a section. I've grabbed some screenshots of the view hierarchy and the constraints related to the view (Foreground view) I show in the cell.

enter image description here enter image description here

EDIT 2:

If I set the top and bottom constraint to -2 instead of 0, there's no flickering at all, however it's not as I want it visually. So the flickering is not related to the separators at all.

like image 578
Recusiwe Avatar asked Aug 19 '18 15:08

Recusiwe


3 Answers

Trick for removing the cell separators.

Objective-C

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tableView.tableFooterView = [UIView new];
}

Swift

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.tableFooterView = UIView()
}
like image 131
iAleksandr Avatar answered Oct 18 '22 11:10

iAleksandr


Usually flickering happens when you're returning a wrong heightForRowAtIndexPath.
In your case, you're returning a little smaller than your cell's actual height I guess.
So try to set "clipToBounds" of your cell to "true" and check if it works.

like image 40
arturdev Avatar answered Oct 18 '22 13:10

arturdev


Try setting "Renders with edge antialiasing" to YES in your info.plist.

like image 30
Karthick Ramesh Avatar answered Oct 18 '22 11:10

Karthick Ramesh