Ios 为什么UIImageView没有';在滚动之前是否显示四舍五入?

Ios 为什么UIImageView没有';在滚动之前是否显示四舍五入?,ios,swift,uicollectionview,uicollectionviewcell,cornerradius,Ios,Swift,Uicollectionview,Uicollectionviewcell,Cornerradius,我的UIImageView在滚动或重新加载集合视图时不会显示(collectionView.reloadData()) 这就是它的样子: 不舍入 四舍五入 单元格有多个图像视图,所有视图都被约束为使用facescocontainerui视图约束 我尝试在collectionView(\uCollectionView:UICollectionView,cellForItemAt indexPath:indexPath)中实现此代码。: 此外,我还尝试在自定义单元格类中的awakeFro

我的
UIImageView
在滚动或重新加载集合视图时不会显示(
collectionView.reloadData()

这就是它的样子:

  • 不舍入

  • 四舍五入

单元格有多个图像视图,所有视图都被约束为使用
facescocontainer
ui视图约束

我尝试在
collectionView(\uCollectionView:UICollectionView,cellForItemAt indexPath:indexPath)中实现此代码。

此外,我还尝试在自定义单元格类中的
awakeFromNib()
方法中添加上面的代码片段,但它不起作用


为什么它不起作用?如何修复它?

在viewWillLayoutSubviews中设置半径将解决此问题

override func viewWillLayoutSubviews(){
super.viewWillLayoutSubviews()
profileImageView.layer.cornerRadius=profileImageView.frame.height/2.0

}

在ViewWillLayoutSubView中设置半径将解决此问题

override func viewWillLayoutSubviews(){
super.viewWillLayoutSubviews()
profileImageView.layer.cornerRadius=profileImageView.frame.height/2.0

}

我想你应该把你的代码放在这里面:

DispatchQueue.main.async {
   // your view configurations
}

我认为你应该把你的代码放在这里面:

DispatchQueue.main.async {
   // your view configurations
}

您是否在willdisplaycell方法中尝试过此操作?
awakeFromNib
中不存在约束。查看此帖子-解释和解决方案:您是否在willdisplaycell方法中尝试过此操作?
awakeFromNib
中不存在约束。查看此帖子-解释和解决方案: