我不确定为什么我的图像在我的 tableview 单元格中的宽度不相同
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
if (self.mySearchController.active)
{
cell.imageView?.contentMode = UIViewContentMode.ScaleAspectFill
cell.imageView?.frame = CGRectMake(40, 60, 60, 24)
cell.imageView?.image = decodedimage
cell.imageView?.clipsToBounds = true
return cell
}}
输出:
如何在将所有图像设置到我的单元格之前使其具有固定宽度
最佳答案
UITableViewCell.imageView 将调整图像大小以适合单元格高度。如果你想有一个固定的宽度,你可以试试这个:
image = [UIImage imageWithCGImage:decodedimage.CGImage
scale:fixedWidth / decodedimage.width
orientation:decodedimage.imageOrientation];
关于iOS 在 uitableview 单元格中设置图像宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31835540/