Reputation: 881
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:
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).
Upvotes: 5
Views: 3650
Reputation: 568
Due to improper width constraint this thing is happened. Either You need to add proportional width or you should run in that device for which you have designed.
Upvotes: 0
Reputation: 1039
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.
Upvotes: 5