这是我启动应用时的结果
点击单元格后,图像变大了
我的代码就像这样
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath)
// Configure the cell...
cell.imageView?.sd_setImageWithURL(NSURL(string: imageArray[indexPath.row]), placeholderImage:UIImage(named: "pin.png"))
cell.imageView?.frame = CGRectMake(0, 0, 50, 50)
return cell
}
imageArray只是图片网址的字符串。请帮忙
提前致谢
答案 0 :(得分:1)
您可以尝试使用内容模式属性:
imageViewObject.contentMode = UIViewContentMode.ScaleToFill
或
imageViewObject.contentMode = UIViewContentMode.ScaleAspectFit
或
imageViewObject.contentMode = UIViewContentMode.ScaleAspectFill
答案 1 :(得分:0)
尝试在sd_setImageWithURL
的完成闭包中设置框架cell.imageView?.sd_setImageWithURL(NSURL(string: "Your URL")!, placeholderImage: nil) { (image, error, cache, url) in
cell.imageView?.frame = CGRectMake(0, 0, 50, 50)
}
希望这有帮助。
答案 2 :(得分:0)
视图必须更大,然后原始图片视图现在提供 backgruond颜色 来查看并在该视图中提供图片图即可。它可能看起来像图像的固定大小,但有背景。