I'm having trouble centring a UILabel in a tableview cell. I set the constraints in a prototype cell, and everything seems to be okay, but when running the label actually shows up at the left side of the cell. Any idea why this happens and how to fix it?
It looks like you fill wrong label. Make sure you set value to myLabel
, cell.myLabel.text = "9:00"
, and not to cell.textLabel?.text
.
As much as I hate to answer my own question, but I will leave it here, maybe helps someone in the future...
The problem was solved using this . The tableview cell had its own class. The content view had to be set to UIView instead of the custom class. The cell itself still keeps the properties of your custom class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.