Ios 当选择Aspect Fit内容模式时,UIImageView会在UITableView单元格中留下大量空白

Ios 当选择Aspect Fit内容模式时,UIImageView会在UITableView单元格中留下大量空白,ios,swift,Ios,Swift,我使用内容模式AspectFit的UIImageView,但我的url图像在顶部和底部留下空白 我已经尝试过使用比例填充和方面填充模式,但它没有按照要求工作 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let row = indexPath.row if(row == 0){ let

我使用内容模式AspectFit的UIImageView,但我的url图像在顶部和底部留下空白

我已经尝试过使用比例填充和方面填充模式,但它没有按照要求工作

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let row = indexPath.row

        if(row == 0){

          let cell  = tableView.dequeueReusableCell(withIdentifier: "PostNewCellIdentifier", for: indexPath) as! PostNewTableViewCell

            cell.postTitleLbl.text = commonContentList[0].commonTitle
            cell.postDateLbl.text = commonContentList[0].commonCreatedAt
           return cell


        }else if(row == 1){
            let  cell = tableView.dequeueReusableCell(withIdentifier: "PostNewSecondTableViewCellIdentifier", for: indexPath) as! PostNewSecondTableViewCell

            cell.logoURL = commonContentList[0].commonImage


             return cell
        }else if(row == 2) {

            let  cell = tableView.dequeueReusableCell(withIdentifier: "PostNewThirdTableViewCellIdentifier", for: indexPath) as! PostNewThirdTableViewCell
            cell.postDescLbl.text = postDescription

            return cell
      }
}

如果您还没有设置,
ImageView
的第一个大小约束。然后切换到“缩放以填充”,并选中属性检查器中的“剪辑到边界”框

有人能帮我找到这个问题的正确答案吗。非常感谢您的帮助。您需要设置单元格高度以匹配缩放图像的高度。查看一个应该有帮助的教程。从Apple docs-它似乎对我不起作用,因为我的图像类型是URL。我的ImageView约束是top=superview,bottom=superview,trailing=9,前导=9,当我选择“剪辑到边界”时,“缩放到填充”图像高度似乎是huge@Sushildhakal我在我当前的项目中使用了相同的方法,而且效果很好。我很确定你的问题在于约束。我不能不看你的项目就说什么,但是,要么你连接到错误的superview,要么其他元素没有约束,要么它们是模糊的。Gul,正如我前面提到的,关于我的约束,我也遵循了你提供的说明,但它对我不起作用。@Gushil,正如我说的,你将顶部和底部连接到错误的superview。确保它们连接到单元的框架上。