在运行时更改静态UITableView的高度

时间:2013-04-02 06:40:22

标签: ios objective-c uitableview

当我改变单元格的高度时,我需要在运行时更改UITable的高度。

我的tableView是静态的,无法滚动

enter image description here

我在下一个方法中更改了tableView的高度(我的意见是非常糟糕的决定,所以我请你帮忙):

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.tableView) {
        self.tableView.originY = 95;
        self.tableView.height = self.tableView.contentSize.height + 2;
        self.tableViewBottom.originY = tableView.originY + tableView.height + 15;
        self.scrollView.contentSize = CGSizeMake(self.scrollView.width, self.tableViewBottom.originY + self.tableViewBottom.height + 10);
    }
}

self.tableView的问题,其中clls可能会改变大小。 self.tableViewBottom第二个tableView,位于第一个。

所以我有下一个:

enter image description here

点击时:

enter image description here

有时tableView在点击后更改y上的位置(你可以看到图像中的大小比第一种情况更多)所以我认为代码中的第一个字符串可能会有所帮助:self.tableView.originY = 95;

enter image description here

为什么我在故事板高度为100

enter image description here

我的tableView只显示一个单元格,因此tableView的高度不会以编程方式更改;

enter image description here

修改 答案中没有人能帮助我,这完全取决于细胞高度的变化。我想在显示所有单元格后我需要更新uitableview的高度。我该怎么做?

0 个答案:

没有答案
相关问题