表视图细胞"跳"从视图控制器回去时,表视图控制器 [英] Table View Cells "jump" when going back from View Controller to Table View Controller

查看:105
本文介绍了表视图细胞"跳"从视图控制器回去时,表视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 TableViewController ,并单击自定义单元格带你到一个相关的 WebViewController

I have a TableViewController, and clicking on a custom cell takes you to a related WebViewController.

我遇到的问题是,当我点击返回在 TableViewController WebViewController 表格视图单元C>跳。

The problem I'm having is that when I tap "Back" in the WebViewController the Table View Cells in TableViewController "jump".

一旦表视图开始滚动他们立刻回到正确的高度。所以我假设它是与在 TableViewController 定制单元的高度,但我不能完全确定。

Once the Table View starts scrolling they all jump back into the right heights. So I'm assuming it has something to do with heights on the TableViewController custom cells, but I'm not totally sure.

TableViewController.m

试过:

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    id model = self.Model[indexPath.row];

    if ([model isKindOfClass:[Two self]]) {
        return 490; // As of 11/13/14
    } else { // 2 other custom cells
        return tableView.rowHeight; // return the default height
    }
}

也试过:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    id model = self.Model[indexPath.row];

    if ([model isKindOfClass:[One self]]) {
    ListTableViewCell *cellOne = [tableView dequeueReusableCellWithIdentifier:@"1Cell"];
    CGFloat heightOne = [cellOne.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    return heightOne + 2;

    } else if ([model isKindOfClass:[Two self]]) {
    ListTableViewCellTwo *cellTwo = [tableView dequeueReusableCellWithIdentifier:@"2Cell"];
    CGFloat heightTwo = [cellTwo.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    return heightTwo + 400;

    } else if ([model isKindOfClass:[Three self]]) {
    ListTableViewCellThree *cellThree = [tableView dequeueReusableCellWithIdentifier:@"3Cell"];
    CGFloat heightThree = [cellThree.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    return heightThree + 2;

    } else {
        return 300;
    }
}

更新:

也试过 [单元setNeedsUpdateConstraints]; [单元setNeedsLayout];

也已经尝试设置 estimatedHeight 多个不同的斑点,并且还增加了自动行维度亦随这一点。

Also have tried setting estimatedHeight multiple different spots, and also added Automatic Row Dimension in tandem with that.

帮助将AP preciated!会后所需的任何额外的信息。谢谢!

Help would be appreciated! Will post any extra info needed. Thanks!

我只支持iOS版8.我使用自动布局和故事。

其他故事板信息自定单元2:

Additional Storyboard info for Custom Cell 2:

故事板的限制:

推荐答案

我相信你没有正确设置约束。我有之前与此类似,并通过前置,顶部和底部间隔的限制设置为的UILabel解决的问题。

I believe that you didn't set the constraint properly. I had the a problem similar to this before and solved by setting the constraints on Leading, Trailing, Top and Bottom spacing to the UILabel.

玩的约束。行为将开始改变。继续下去,直到你得到你想要的东西。

Play around with the constraints. behavior will start change. keep going until you get what you want.

这似乎不是因为从专业的一个decesnt技术性的回答也。但是,这如何解决越来越与苹果不正确的出台虚拟约束。

It doesn't seem as a decesnt technical answer from a professional. But, that how it getting solved with those dummy constraint which apple doesn't introduced properly.

此外,尝试 [单元setNeedsUpdateConstraints]; 你的cellForRowAtIndexPath返回单元格之前。
和: [单元setNeedsLayout];

这篇关于表视图细胞"跳"从视图控制器回去时,表视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆