I'm currently developing an application in Swift and, when i run my application on an iPhone 6 (which runs iOS 12.4.6), occurs a strange problem.
I have a UITableView
with many of UITableViewCell
inside it and, these cells, contain a UIButton
which backgroundColor
needs to be updated by a specific condition. The problem is that, only the first cell, doesn't load correctly the color, on the contrary it's loaded only after the cell is reused by the UITableView
.
I've had a similar problem before (on the same device) inside a UIViewController
and I barely resolved it by shifting the code used to control the backgroundColor
from the viewDidLoad
method to the viewWillLayoutSubviews
method.
In my opinion it's something related with the storyboard overriding some values, I've already tried to set the condition on awakeFromNib
inside the UITableViewCell
but nothing changes, and I can't actually figure out what else may be causing this problem.