Alexandru Vasiliu Alexandru Vasiliu - 5 months ago 16
iOS Question

Custom cells labels and button appear only when tapped

I am developing a Swift application. I have 2 tables which I populate them from file. My problem regards the 2nd table which displays the labels and buttons only when pressed. If I press the cell, the labels and buttons appear, as soon as I stop tapping the cell, they dissapear. I want the buttons and labels be available without being tapped.

Answer

You have your code to spawn the buttons in the .init of your UITableViewCell However you never use this initializer in your cellFoRowAtIndexPath

If you move the initialization of your cell in a separate function for example configureCell() and call that function from every initializer in the custom class. For example:

override func awakeFromNib() {
    super.awakeFromNib()
    configureCell()
}

Then you should have no problem