【问题标题】:Update Cell's Constraints after Editing Table View编辑表格视图后更新单元格的约束
【发布时间】:2015-05-23 01:46:19
【问题描述】:

我遇到了自动布局问题,当我进入表格视图的编辑模式时,单元格的标签会更新以适应一个小空间(这看起来不错)。问题是在退出编辑模式时,标签的约束不会更新以适应更大的 contentView。这是我解决此问题的尝试。任何人有任何想法我应该如何做到这一点?

-(void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing:editing animated:animated];
    for (UITableViewCell *cell in [self.tableView visibleCells]) {
        [cell.contentView setNeedsUpdateConstraints];
    }
}

【问题讨论】:

    标签: ios objective-c uitableview xcode6


    【解决方案1】:

    尝试使用layoutIfNeeded

    for (UITableViewCell *cell in [self.tableView visibleCells]) {
        [cell.contentView setNeedsUpdateConstraints];
    }
    

    【讨论】: