Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 3: UILabel not showing in custom UITableViewCell

I have a custom UITableViewCell called CCLineupTableViewCell that looks like this:

@IBOutlet weak var artistNameLabel: UILabel!
@IBOutlet weak var artistValuationLabel: UILabel!

override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code

}

override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)

    // Configure the view for the selected state
}

I access the cell in the cellForRowAt indexPath: IndexPath method like so:

let cell = tableView.dequeueReusableCell(withIdentifier: "HomeCell", for: indexPath) as! CCLineupTableViewCell

My custom cell setup is like so:

enter image description here

enter image description here

As you can see it's setup right in the IB and in the code. The weird thing is that the first label, artistNameLabel, is accessible through cellForRowAt indexPath: IndexPath and works perfectly. The artistValuationLabel, however, never even shows up despite having default text via the storyboard.

Edit:

I've added a picture of the constraints from the nib. It's anchored to the right side, top, and bottom of the cell (as well as the aspect ratio).

enter image description here

like image 724
Clayton C. Avatar asked Apr 02 '17 18:04

Clayton C.


1 Answers

Your mistake is an error on the constraints you did set.

Add a Width constraint to make sure that artistValuationLabel will have space to appear.

like image 65
Santiago Carmona González Avatar answered Oct 17 '22 04:10

Santiago Carmona González