- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"cell";

    UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];


        }


    tv.rowHeight = UITableViewAutomaticDimension;
    tv.estimatedRowHeight = 44.0;
    [cell setNeedsUpdateConstraints];
    [cell updateConstraintsIfNeeded];

    NSDictionary *Data5 = [pro1 objectAtIndex:indexPath.row];
    NSString *name = [Data5 objectForKey:@"handle"];


      UIButton *c3 = (UIButton *)[cell viewWithTag:775];


    NSLayoutConstraint *height = [NSLayoutConstraint
                                  constraintWithItem:c3
                                  attribute:NSLayoutAttributeHeight
                                  relatedBy:NSLayoutRelationEqual
                                  toItem:nil
                                  attribute:0
                                  multiplier:0
                                  constant:70];


    NSLayoutConstraint *height2 = [NSLayoutConstraint
                                  constraintWithItem:c3
                                  attribute:NSLayoutAttributeHeight
                                  relatedBy:NSLayoutRelationEqual
                                  toItem:nil
                                  attribute:0
                                  multiplier:0
                                  constant:0];

    [c3 removeConstraint:height];
    [c3 removeConstraint:height2];
    [c3 addConstraint:height];


 if ([name isEqualToString:@"abcd"]) {


            UITableViewCell *updateCell2 = (id)[tableView cellForRowAtIndexPath:indexPath];


            if (updateCell2){


                    [c3 removeConstraint:height];
                    [c3 removeConstraint:height2];
                    [c3 addConstraint:height2];
                }


 }else{

         [c3 removeConstraint:height];
         [c3 removeConstraint:height2];
         [c3 addConstraint:height];


 }

    return cell;
}

在第一次加载时,条件工作正常 . 根据if else条件,c3按钮高度在第一次加载时是完美的 . 但当我向上滚动然后所有c3按钮采取“height2”约束 . 如果其他条件搞砸了 . 你能帮我吗?

结构是:

-tableview --cell --- contentview ---- view ----- button(c3)