Setting cells height gives me error

Jessica

I have a UIView in a UITableViewCell. I'm trying to change the height of the view with an animation. Here is what I did:

self.myViewConstraint.constant = 100; // Coming from 0
[UIView animateWithDuration:0.3f animations:^{
        [self.view layoutIfNeeded];        
    }];

The only thing is, it's in a tableView. So here's what I did for the heightForRow...:

return self.myViewConstraint.constant == 0 ? 74 : 174;

Now I need to update the tableView, so I inserted in animateWithDuration:

[self.tableView beginUpdates];
[self.tableView endUpdates];

Because I have other things inside the the cell, so the constraints get messed up while the cells height is animating. How can I update the cells height without getting the constraints messed up? (I want the cells height to animate.)

Here is the warning I get. (Everything works fine, but I just want to remove the warning.)

Edit I changed it a bit, and I now get this error:

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:0x7f8d62d15670 V:[tagResultTableView:0x7f8d62d901a0(107)]>",
    "<NSLayoutConstraint:0x7f8d62cea010 tagResultTableView:0x7f8d62d901a0.top == UITableViewCellContentView:0x7f8d62d8fd50.topMargin - 8>",
    "<NSLayoutConstraint:0x7f8d62cf0760 V:[tagResultTableView:0x7f8d62d901a0]-(8)-[UILabel:0x7f8d62d2e2e0'Limit: Up to 5 tags']>",
    "<NSLayoutConstraint:0x7f8d62cf0800 UILabel:0x7f8d62d2e2e0'Limit: Up to 5 tags'.bottom == UITableViewCellContentView:0x7f8d62d8fd50.bottomMargin>",
    "<NSLayoutConstraint:0x7f8d62f726d0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7f8d62d8fd50(32)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f8d62d15670 V:[tagResultTableView:0x7f8d62d901a0(107)]>
user3480295

Here is an example.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return self.myViewConstraint.constant == 0 ? 74 : 174;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ReuseID];
    if (!cell) {
        cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ReuseID];
    }
    if (self.myViewConstraint.constant != 0) {
        [cell doAnimation];
    }

    return cell;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Reading a range of cells in an Excel doc gives me an error

From Dev

Reading a range of cells in an Excel doc gives me an error

From Dev

MySQL 'AND' gives me error

From Dev

It gives me an error at GPS

From Dev

Setting a cookie with php within JS gives me an error on line 29, returning a variable from PHP code?

From Dev

Yii2- Setting user id to null gives me non-object error

From Dev

Animate UITableViewCell gives me error

From Dev

Sorting array gives me error

From Dev

php header gives me the error

From Dev

.getDownloadUrl() gives me error - Android

From Dev

using "this" in a fragment gives me an error

From Dev

Sorting array gives me error

From Dev

Animate UITableViewCell gives me error

From Dev

Firefox gives me dbus error

From Dev

Jquery $(window).height() gives wrong value when setting height for document element

From Dev

Jquery $(window).height() gives wrong value when setting height for document element

From Dev

Pip freeze gives me this error related with git

From Dev

Create empty array of struct gives me an error

From Dev

Change UITableViewCell size gives me an error

From Dev

Devise confirmation link gives me routing error

From Dev

<~ in elm 0.16.0 gives me a compile time error

From Dev

Rails Generate Controller gives me load error

From Dev

Wildfly Resteasy gives me 404 error and no logging

From Dev

Why triggerHandler(event) gives me an error?

From Dev

Istanbul gives me coverage but ends output with an error

From Dev

Fragment gives me an error while inflating 1

From Dev

WWW POST gives me Internal Server Error

From Dev

pyserial with multiprocessing gives me a ctype error

From Dev

Rails Generate Controller gives me load error

Related Related

HotTag

Archive