【发布时间】:2016-02-25 18:54:01
【问题描述】:
单击单元格后,我找不到 cell.imageView 更改的任何原因。似乎只有宽度变化。在我的代码中,图像帧应该是第二张图片中的 iPhone。
imageView 是 Swift 内置的,不是我在 tableviewcell 中的自定义名称。
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
if tableView == resultsTable {
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MarketCell")
var supplyDetail = String()
var frame = cell.imageView!.frame
let imageSize = 50 as CGFloat
frame.size.height = imageSize
frame.size.width = imageSize
cell.imageView!.frame = frame
cell.imageView!.layer.cornerRadius = imageSize / 2.0
cell.imageView!.clipsToBounds = true
cell.imageView?.image = UIImage(named: "Profile Picture")
...getDataInBackgroundWithBlock...
cell.imageView?.image = UIImage(data: data!)!
return cell
}
}
点击前,
点击后,
【问题讨论】:
-
您发布的代码建议图像视图应始终为 50 x 50,但您说第二张图像是正确的,但只有一个图像视图是 50 x 50。发布与设置相关的所有代码图像视图的大小。
-
正确的应该是第二张图片中的iPhone。这就是与图像大小相关的所有代码。我试图划掉从 var frame 到 cell.imageView.clipToBounds 的所有行。同样的事情也会发生。我想知道属性检查器有什么需要注意的吗?
-
请不要显示虚假的代码摘要。显示真实代码。
-
已更新。它很长。这就是我总结它的原因。哈哈
-
啊。你在使用自动布局吗?
标签: swift image uitableview uiimageview cell