I have several UITableViewCell
's that have custom buttons in them. These buttons cover up the text in a few of the cells. How do I set the width of the textLabel
attribute within the cell so this doesn't happen? This doesn't seem to work.
cell.textLabel.font = UIFont.boldSystemFontOfSize(16)
cell.textLabel.adjustsFontSizeToFitWidth = true
cell.textLabel.numberOfLines = 0
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap
cell.textLabel.preferredMaxLayoutWidth = 200
I am running this in the tableView(table_view, willDisplayCell:cell, forRowAtIndexPath:index_path)
method.
Setting the frame at this time doesn't work either.
如果您需要UITableViewCell
看起来比默认行为更好,您应该在自己的视图子类中绘制完整内容,以便自定义按钮和文本以及可能的其他信息,并将其作为单元格的视图返回。
Probably create/alloc a UILabel and add it to the cell instead. That way you can set its frame.
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.