1

我有一个自定义UITableView - Scroll, Paging Enable。因为我的每个单元格都有一个背景图像,所以我希望每次向上或向下滚动时都会将每个图像显示为全屏。我尝试将我的UITableViewCell 设置为全屏(将其高度拉伸为与 tableview 一样大)。

但是,我遇到了一个问题:当我滚动(分页)时,单元格不会全屏显示。它包含下一个单元格的一小部分。然后每次我向下滚动(分页)时,下一个单元格的部分会越来越大。

我没有看到 UITableViewCell 的任何自动布局选项,无法向原型单元格添加约束。你能建议我这样做的方法吗?非常感谢。

4

2 回答 2

2

// ***** 下面的 SWIFT 函数将单元格图像视图扩展到全屏 (frame.size.height),添加到上面 M.Salah 的回复中。

    override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return tableView.frame.size.height;
}
于 2015-03-27T06:35:15.413 回答
2

我只是添加了这两行代码,它对我有用

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return tableView.frame.size.height;
}
于 2015-02-16T13:54:58.540 回答