简体   繁体   中英

Xcode tableViewcell Autolayout issue

Im having a problem with autolayout working properly in my custom tableviewcell. I cant seem to figure out the problem behind it. Ok, so my tablecell looks like so in the storyboard

在此处输入图片说明

I have pinned the title label to the both side and the top. The dotted line below is a UIImageView which is also pinned to both sides and then to title above it. It is also set to a height of 1. no complaints so far.

The content label is where I seem to have the issue. I have pinned the content label to both sides and to the image view above it. Its also pinned to the bottom of the cell to complete the top to bottom constraints. Ive also set the number of lines to 0 too.

Ok so in my code I have

    tableView.rowHeight = UITableViewAutomaticDimension
    tableView.estimatedRowHeight = 67.0

When I run my project I get these results. Note I have the background of the content label in red to for debugging only and I have the same string in each cell for now, but it should stretch to a multiline cell.

在此处输入图片说明

Is there something that I overlooked here?

Got it, It seems I needed to check the preferred width checkbox.

在此处输入图片说明

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM