【问题标题】:querying data and images into a tableview from parse.com using swift使用 swift 从 parse.com 将数据和图像查询到 tableview
【发布时间】:2015-09-30 22:44:25
【问题描述】:

我希望使用 swift 将数据和图像查询到 tableview 中,但我似乎找不到任何教程或任何显示如何做到这一点的东西。在我的解析类中,我有一个名为Products 的类,在该类中我有一个名为productNameproductImageproductDescription 的列。比在我的表格视图中,我有它显示图像和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


    【解决方案1】:

    看看:https://parse.com/docs/ios/guide#user-interface-pfquerytableviewcontroller,这是 Parses 自己的用户界面,它从解析查询中生成表视图。它还解释了如何向单元格添加缩略图。每个单元格都将包含对象,因此您可以轻松地选择单元格所代表的图像。我希望这会有所帮助!

    【讨论】:

    • 仍然很难。我发布了似乎有问题的代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-16
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    相关资源
    最近更新 更多