【发布时间】:2015-09-30 22:44:25
【问题描述】:
我希望使用 swift 将数据和图像查询到 tableview 中,但我似乎找不到任何教程或任何显示如何做到这一点的东西。在我的解析类中,我有一个名为Products 的类,在该类中我有一个名为productName、productImage 和productDescription 的列。比在我的表格视图中,我有它显示图像和productName 的位置。当您单击单元格查询到 viewController 以在 textView 中显示图像、名称和描述时,这是假设的。如果有人可以请帮我一把,将不胜感激!
// Display product image
var initialThumbnail = UIImage(named: "question")
cell.ProductImage.image? = initialThumbnail!
if let thumbnail = object?["productImage"] as? PFFile {
cell.ProductImage.file = thumbnail
cell.ProductImage.loadInBackground()
}
这段代码似乎有问题,因为当我运行我的应用程序时,它只显示我的问题标记图片,而不是来自解析的图像。
更新: 我能够显示我的图片我没有正确的类中的 UIImage。但是,单击单元格后,我仍然无法让图像与视图控制器中的其他数据一起显示。只显示描述和名称。有什么想法吗?
这是我发布的图片:vvvvvv 很确定我必须在此处添加一些内容,但不确定从表格视图中选择产品时要查询什么图像
更新:找出问题所在。我添加了这段代码,它现在可以工作了。
if let object = currentObject {
productName.text = object["productName"] as? String
productDescription.text = object["productDescription"] as! String var initialThumbnail = UIImage(named: "question")
ProductImage.image? = initialThumbnail!
if let thumbnail = object["productImage"] as? PFFile {
ProductImage.file = thumbnail
ProductImage.loadInBackground()
【问题讨论】:
标签: ios swift parse-platform tableview querying