Uitableview 从SDWebimage加载/下载图像并在自定义tableView单元格imageView中显示

Uitableview 从SDWebimage加载/下载图像并在自定义tableView单元格imageView中显示,uitableview,swift3,sdwebimage,Uitableview,Swift3,Sdwebimage,我已经解析了其他值,但是如何将图像显示到imageView我已经在Swift中使用了SdWebImage。我想在下面的单元格中显示“detail”是我的代码 import UIKit import SystemConfiguration import MBProgressHUD public struct Section { var arrayDataTop: String var arrayTerms: String var qrImage:String v

我已经解析了其他值,但是如何将图像显示到
imageView
我已经在Swift中使用了SdWebImage。我想在下面的单元格中显示“detail”是我的代码

import UIKit
import SystemConfiguration
import MBProgressHUD


public struct Section {
    var arrayDataTop: String
    var arrayTerms: String
    var qrImage:String
    var collapsed: Bool

    public init( arrayDataTop: String,qrImage: String ,arrayTerms: String, collapsed: Bool = false) {
        self.arrayDataTop = arrayDataTop
        self.qrImage = qrImage
        self.arrayTerms = arrayTerms
        self.collapsed = collapsed
    }
}

class CollapsibleViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {
@IBOutlet weak var tableViewCollapsible:UITableView!
@IBOutlet weak var listImage:UIImageView!

var nodatastr:String = "No Deal Found."
var dealIDCollapsible : String?
var dealDictCollapsible = [String: AnyObject]()
var parentNavigationController: UINavigationController?
private var loadingView:MBProgressHUD?

var sectionDataObj = [Section]()


override func viewDidLoad() {
    super.viewDidLoad()

    if (!self.isInternetAvailable()){

        self.alertMessageShow(title: "No Internet Connection", message: "Make sure your device is connected to the internet.")
    }
    else{
        if self.loadingView == nil {
            self.loadingView =  MBProgressHUD.showAdded(to: self.view, animated: true)
        }


        tableViewCollapsible.estimatedRowHeight = 100.0
        tableViewCollapsible.layoutIfNeeded()
        tableViewCollapsible.updateConstraintsIfNeeded()
        tableViewCollapsible.tableFooterView = UIView()


        self.listImageFetch()
        dealFetchParticularListing()
    }
}








func dealFetchParticularListing(){

    let prs = [
        "listing_id":dealIDCollapsible,//dealIDCollapsible,
        "Deal_fetch_listing": "1" as String
    ]
    Service.CreateDeal(prs as [String : AnyObject]?, onCompletion: { result in
        let json = result as? NSDictionary
        if let data = json as? [String:Any]{
            if let err = data["status"] as? String, err == "success"{
                if let data = data["result"] as? [Any]{
                    //
                    //fill your data in that local Section obj
                    //
                    var sectionDataObj = [Section]()
                    for sectionObj in data{
                        if let sectionObjVal = sectionObj as? [String:Any]{
                            if let qrcode = sectionObjVal["qrcode"] as? String{
                                if let tnc = sectionObjVal["tnc"] as? String{
                                    if let deal_title = sectionObjVal["deal_title"] as? String{
                                        let sectionValue = Section(arrayDataTop: deal_title, qrImage: qrcode, arrayTerms: tnc)
                                        // access main objects/UIelement on main thread ONLY
                                        sectionDataObj.append(sectionValue)

                                    }
                                }
                            }
                        }
                    }
                    DispatchQueue.main.async { () -> Void in
                        self.sectionDataObj.removeAll()
                        //
                        //assign ur data in main sampleData(Section obj) then reload tableView with that data.
                        //
                        self.sectionDataObj = sectionDataObj
                        self.tableViewCollapsible.reloadData()
                        self.loadingView?.hide(true)
                    }
                }
            }
        }
    })
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {


    // Header
    if indexPath.row == 0 {
        let cell = tableView.dequeueReusableCell(withIdentifier: "header") as! MyCellData
        cell.lblDealTitle.text = sectionDataObj[indexPath.section].arrayDataTop
        return cell
    }
    // Cell
    let cell = tableView.dequeueReusableCell(withIdentifier: "detail") as! MyCellData
    cell.lblTerm.text = sectionDataObj[indexPath.section].arrayTerms
    // here i want to show image 
    return cell
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension//320.0
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if indexPath.row == 0 {
        let collapsed = !sectionDataObj[indexPath.section].collapsed
        // Toggle collapse
        sectionDataObj[indexPath.section].collapsed = collapsed
        self.tableViewCollapsible.reloadSections([indexPath.section], with: .automatic)
    }
}
 }



class MyCellData:UITableViewCell{

    @IBOutlet weak var lblDealTitle: UILabel!
    @IBOutlet weak var dealimage: UIImageView!
    @IBOutlet weak var lblTerm: UILabel!
    @IBOutlet weak var qrCodeImage: UIImageView!

}

请帮我解决这个问题。提前谢谢。一切正常。我可以看到其他详细信息。我们将不胜感激。请帮我解决这个问题。

更新ur
tableView cellForRowAt
这样显示ursectionDataObj

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {


    // Header
    if indexPath.row == 0 {
        let cell = tableView.dequeueReusableCell(withIdentifier: "header") as! MyCellData
        cell.lblDealTitle.text = sectionDataObj[indexPath.section].arrayDataTop
        return cell
    }
    // Cell
    let cell = tableView.dequeueReusableCell(withIdentifier: "detail") as! MyCellData
    cell.lblTerm.text = sectionDataObj[indexPath.section].arrayTerms
    let imgUrl = sectionDataObj[indexPath.section]. qrImage
    cell.qrCodeImage.sd_setImage(with: URL(string:imgUrl), completed: nil)
    return cell
}

让我检查一下,但我正在将json“qrcode”的字符串响应保存到structhi@Govind Kumawat,你能帮我回答这个问题吗?将图像设置为
UIImageView
单元格内的插座
cellForRowAt