Updating UITableViewCell Constraints Throws Exception

I am using Xcode 5 with the iOS 7 SDK. I have a UITableViewCell defined as a prototype in my storyboard, and I use autolayout for subviews inside the cell. When a cell is requested cellForRowAtIndexPath, I populate the cell with my data:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ActivityTableViewCell *tableViewCell = [tableView dequeueReusableCellWithIdentifier:@"Activity"];
    Activity *activity = self.activities[(NSUInteger)indexPath.row];

    [tableViewCell configureWithActivity:activity];

    return tableViewCell;
}

These data can lead to a change in the height of one of the subzones. I change the height of the subspecies, changing its restriction, as well as other modifications to the restrictions:

@implementation ActivityTableViewCell

- (void)updateConstraints
{
    // Update constraints based on the activity
    self.activityDocumentsTableViewHeightLayoutConstraint.constant = ...;
    self.betweenActivityDocumentsTableViewAndNotesLabelLayoutConstraint.constant = ...;
    self.activityNotesTableViewHeightLayoutConstraint.constant = ...;
    self.betweenActivityNotesTableViewAndContentViewLayoutConstraint.constant = ...;

    [super updateConstraints];
}

- (void)configureWithActivity:(Activity *)activity
{
    // Populate subviews using the activity variable

    [self setNeedsUpdateConstraints];
}

@end

My ActivityTableViewCell class comes from another class that reports that viewing content automatically depends on its dynamic sizes:

self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

My view controller pre-calculates the heights of all these cells and stores them in an array. These heights are delivered in heightForRowAtIndexPath.

, :

2014-01-17 10:41:47.435 ... Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x13c4a520 UnknownLabel:0x13c4a440.height == 26>",
    "<NSLayoutConstraint:0x13c4ad20 BorderedTableView:0xd46e000.height == 54>",
    "<NSLayoutConstraint:0x13c4b800 UnknownLabel:0x13c4b720.height == 26>",
    "<NSLayoutConstraint:0x13c4be40 BorderedTableView:0xd462600.height == 74>",
    "<NSLayoutConstraint:0x13c4cc60 BorderedTableView:0xd46e000.top == UnknownLabel:0x13c4a440.bottom + 8>",
    "<NSLayoutConstraint:0x13c4ccc0 BorderedTableView:0xd462600.top == UnknownLabel:0x13c4b720.bottom + 8>",
    "<NSLayoutConstraint:0x13c4cd20 UITableViewCellContentView:0x13c49de0.bottom == BorderedTableView:0xd462600.bottom + 8>",
    "<NSLayoutConstraint:0x13c4cd50 UnknownLabel:0x13c4a440.top == UITableViewCellContentView:0x13c49de0.top + 20>",
    "<NSLayoutConstraint:0x13c4cd80 UnknownLabel:0x13c4b720.top == BorderedTableView:0xd46e000.bottom + 55>",
    "<NSAutoresizingMaskLayoutConstraint:0xb2c1bf0 UITableViewCellContentView:0x13c49de0.height == UITableViewCellScrollView:0x13c4d000.height>",
    "<NSAutoresizingMaskLayoutConstraint:0xb2c2460 UITableViewCellScrollView:0x13c4d000.height == ActivityTableViewCell:0x13c49be0.height>",
    "<NSAutoresizingMaskLayoutConstraint:0x13935110 ActivityTableViewCell:0x13c49be0.height == 318>"
)

, 318, . 318 . , "<NSLayoutConstraint:0x13c4be40 BorderedTableView:0xd462600.height == 74>" ( , ). , iOS updateConstraints, .

updateConstraints, setNeedsLayout .., . , iOS , . , , updateConstraints - - , , ; , . , , .

+4
1

, , 999 . .

0

All Articles