Thomas
Thomas

Reputation: 2386

UITableViewCell conflicting height constraint

I have a custom tableview cell where I'm letting auto layout manage the height for it.

tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableViewAutomaticDimension

Inside the tableview cell I have a container subview:

contentView.addSubview(calendarEventContainerView)

All the content I'm adding goes in the calendarEventContainerView and I would like the subview to be a minimum of 120pts, but at the same time, I want it to be pinned to the contentView (so that it stretches the contentView out). The only time I can get it to display properly is when I get an error saying my code can't simulatenously satisfy the constraints. Here's my constraint code:

calendarEventContainerView.autoPinEdgeToSuperviewEdge(.Top, withInset: CalendarEventLayout.verticalInset)
calendarEventContainerView.autoPinEdgeToSuperviewEdge(.Leading, withInset: CalendarEventLayout.horizontalInset)
calendarEventContainerView.autoPinEdgeToSuperviewEdge(.Trailing, withInset: CalendarEventLayout.horizontalInset)
calendarEventContainerView.autoPinEdgeToSuperviewEdge(.Bottom)
calendarEventContainerView.autoSetDimension(.Height, toSize: 120, relation: NSLayoutRelation.Equal)

Any ideas what I'm doing wrong?

Upvotes: 1

Views: 679

Answers (1)

nhgrif
nhgrif

Reputation: 62072

For reasons unbeknownst to be, setting the priority of the constraints down to 999 seems to resolve this issue for autosizing UITableViewCells.

Upvotes: 1

Related Questions