【发布时间】:2016-03-02 04:57:24
【问题描述】:
我正在尝试将图像加载到我的 tableview 单元格,但是,图像似乎比 imageview 大并且超出了 imageview 的边界。
我尝试将UIImageView 的contentMode 属性设置为ScaleAspectFit,但这并没有解决我的问题。
代码:
cell.imageView?.contentMode = UIViewContentMode.Center
cell.imageView?.contentMode = UIViewContentMode.ScaleAspectFit
switch (post.priorityLevel){
case "High Priority Posting":
cell.imageView?.image = UIImage(named: "High Priority Posting")
case "Priority Posting":
cell.imageView?.image = UIImage(named: "Priority Posting")
case "General Posting":
cell.imageView?.image = UIImage(named: "General Posting")
default:
print("Priority Level can't be loaded to table")
}
我从界面生成器添加了我的表格视图的屏幕截图以及模拟器上的结果。
【问题讨论】:
-
您可以在 UI 调试中检查图像大小,也可以检查所有约束。如果您能告诉我们您为单元设置了哪些限制条件,那么我们一定可以为您提供帮助。
标签: ios swift uitableview uiimageview