滚动视图后 UITableView 的高度发生变化

Height of UITableView changed after scroll the view

我使用 UIScrollView 和两个 table 视图。其中之一是动态高度更改,因为我在运行时插入单元格,第二个 table 是固定高度。
当应用程序运行并将单元格添加到第一个 table 时,一切正常,它改变了 table 的高度和滚动视图的内容大小的高度。

问题是:当我滚动并且 scrollViewDidScroll 被称为第一个 table 视图的高度 returns 到它的初始高度并且单元格被添加时得到 nil,第二个 table 视图没有产生问题,因为它的高度是固定的。

注意:我使用了约束并删除了它们(问题仍然存在)。

怎么了?我使用 iOS 8 和 xCode 6.1.

感谢您的帮助!

没有代码很难帮到您,但请尝试检查表视图中的函数: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

问题已通过在 UITableView

上添加约束解决
[self addConstraint:[NSLayoutConstraint constraintWithItem:yourButton
                                           attribute:NSLayoutAttributeHeight
                                           relatedBy:NSLayoutRelationEqual
                                              toItem:nil
                                           attribute:NSLayoutAttributeNotAnAttribute
                                          multiplier:1.0
                                            constant:30.0]];

因为我使用自动布局 我希望这个答案对任何人都有帮助