0

I am trying to set the UITableViewCell height based on what is in the cell (Primarily the image). It looks fine on an iPhone 7 Plus, however any smaller devices produce something similar to this.

My code in MainViewController:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

My constraints: enter image description here

What am I doing wrong? I have the height and width constraints set to 'Greater or Equal to' 200. The height and width of the UIImageView on the Storyboard are 370x370

4

1 回答 1

0

我可以通过执行以下步骤自己解决这个问题:

  1. 将我的故事板视图切换到 iPhone SE
  2. 将 UIImageView 设置为“大于或等于”值:275
  3. UIImageView的宽高设置纵横比为1:1

这是一个图像作为示例:

在此处输入图像描述

于 2017-02-25T23:51:54.637 回答