3
votes

I can slide the contentView of TableView cell by change the cell frame in old ios version. However, I can't slide it in Autolayout. In my case, I create a customized table cell, as the following picture:

enter image description here

I have removed all leading and top constraints before sliding the cell, but there'are still some constrains to prevent me sliding cell, such as

"<NSAutoresizingMaskLayoutConstraint:0x8a39c60 h=--& v=--& UITableViewCellContentView:0x8a2f640.midX == + 160>",
"<NSAutoresizingMaskLayoutConstraint:0x8a39ca0 h=--& v=--& H:[UITableViewCellContentView:0x8a2f640(320)]>",
"<NSAutoresizingMaskLayoutConstraint:0x8a39ce0 h=--& v=--& UITableViewCellContentView:0x8a2f640.midY == + 21.5>",
"<NSAutoresizingMaskLayoutConstraint:0x8a39d20 h=--& v=--& V:[UITableViewCellContentView:0x8a2f640(43)]>"

However, if I use

    [self setTranslatesAutoresizingMaskIntoConstraints:NO];

in my custom cell, there's a problem:

*** Assertion failure in -[UITableView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776
2012-12-05 22:45:14.987 Slider[3773:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.'

I don't know how to solve it, please help me.

1

1 Answers

1
votes

I came across this same issue. You get the error when you use

[aView setTranslatesAutoresizingMaskIntoConstraints:NO];

On the cells contentView. Table view cells don't appear to support this setting.

To work around it embed all the content in a container view and add it as a subview of the tableview cell.

See this answer "Auto Layout still required after executing -layoutSubviews" with UITableViewCell subclass