【问题标题】:How to make UITableViewCell display fullscreen (allow paging)?如何使 UITableViewCell 显示全屏(允许分页)?
【发布时间】:2015-04-16 08:56:54
【问题描述】:

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

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

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

【问题讨论】:

  • 如果单元格来自使用自动布局的 .xib / storyboard,则使用自动布局。

标签: ios uitableview swift autolayout scroll-paging


【解决方案1】:

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

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return tableView.frame.size.height;
}

【讨论】:

    【解决方案2】:

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

        override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return tableView.frame.size.height;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-10
      • 2018-07-22
      • 2013-04-27
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多