I'm writing an application where images are downloaded asynchronously and when the images are loaded its scaled but I just want to show as the same size within the UITableViewCell.
我正在编写一个应用程序,在这个应用程序中,图像是异步下载的,当图像被加载时,它会按比例缩放,但我只想在UITableViewCell中显示相同的大小。
Since i'm using auto layout I have tried to change the height constraint through an IB but then I have to change the height of the cell and I though of reloading each cell after downloading each image but not sure if it's a good idea.
由于我使用的是自动布局,我尝试过通过IB改变高度限制,但之后我必须改变单元格的高度,我想在下载每个图片后重新加载每个单元格,但不确定这是不是一个好主意。
Its like the Facebook application where images are loaded and the uitableviewcell is dynamically changed.
它就像Facebook应用程序,图片被加载,uitableviewcell被动态改变。
1 个解决方案
#1
1
Have you tried this delegate method?:
你尝试过委托方法吗?
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
// return downloadedimage.bounds.height etc.
}
Also do not forget to reload data in the viewDidLoad method
也不要忘记在viewDidLoad方法中重新加载数据
tableView.reloadData()
#1
1
Have you tried this delegate method?:
你尝试过委托方法吗?
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
// return downloadedimage.bounds.height etc.
}
Also do not forget to reload data in the viewDidLoad method
也不要忘记在viewDidLoad方法中重新加载数据
tableView.reloadData()