显示图片时,无法识别的选择器被发送到实例

时间:2016-01-23 18:24:52

标签: ios swift parse-platform

我有以下代码//

//  doctorsList.swift
//  iLegaltwo
//
//  Created by Bharath on 10/1/16.
//  Copyright © 2016 Bharath. All rights reserved.
//

import UIKit
import Parse

class doctorsList: UITableViewController {

    @IBOutlet var doctorsListTableView: UITableView!

    var profImages = [PFFile]()
    var doctorName = [String]()
    var doctorRate = [NSDecimal]()
    var doctorPracArea = [String]()
    var doctorExp = [String]()


    var refresher: UIRefreshControl!



    func refresh()
    {
        let query = PFQuery(className: "doctors_Directory")
        query.orderByDescending("createdAt")

        query.findObjectsInBackgroundWithBlock(

            {
                (listll: [PFObject]?, error: NSError?) -> Void in

                if error == nil {
                    // The find succeeded.
                    print("Successfully retrieved \(listll!.count) names of the doctors.")
                    // Do something with the found objects
                    if let objects = listll {
                        for object in objects {
                            print(object)

                            self.profImages.append(object["ProfileImage"] as! PFFile)
                            self.doctorName.append(object["doctor_Name"] as! String)
                            self.doctorExp.append(object["Exp"] as! String)
                            self.doctorPracArea.append(object["Practice_Area"] as! String)


                           // print(object["doctor_Name"] as! String )
                           // self.doctorsname.append(object["doctor_Name"] as! String)
                            //self.lblName.text = object["doctor_Name"] as? String

                        }
                        self.doctorsListTableView.reloadData()
                    }
                    print(self.doctorName.count)
                } else {
                    // Log details of the failure
                    print("Error: \(error!) \(error!.userInfo)")
                }
                self.tableView.reloadData()
                self.refresher.endRefreshing()
        })

    }


    override func viewDidLoad() {
        super.viewDidLoad()

        refresher = UIRefreshControl()
        refresher.attributedTitle = NSAttributedString(string: "Pull to refrehsh")
        refresher.addTarget(self, action: "refresh", forControlEvents: UIControlEvents.ValueChanged)
        self.tableView.addSubview(refresher)

        refresh()




        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return doctorName.count
        //return 6
    }


    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let doctorcell: doctorsListCell = tableView.dequeueReusableCellWithIdentifier("doctorlistproto") as! doctorsListCell

        doctorcell.lblNamell.text = doctorName[indexPath.row]
        doctorcell.lblExpll.text = doctorExp[indexPath.row]
        doctorcell.lblPracareall.text = doctorPracArea[indexPath.row]
        profImages[indexPath.row].getDataInBackgroundWithBlock{(imageData: NSData?, error: NSError?) -> Void in
            if imageData != nil {
                let image = UIImage(data: imageData!)
                doctorcell.imagedoctor.image = image
            }
            else
            {
                print(error)
            } }

        //cell.textLabel?.text = doctorsname[indexPath.row]

        return doctorcell
    }


    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
    {
        print(indexPath.row)
    }

    /*
    // Override to support conditional editing of the table view.
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return false if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            // Delete the row from the data source
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        } else if editingStyle == .Insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return false if you do not want the item to be re-orderable.
        return true
    }
    */

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

修改

doctorListCell类

import UIKit

class doctorsListCell: UITableViewCell {

    @IBOutlet var imagedoctor: UIImageView!
    @IBOutlet var lblNamell: UILabel!
    @IBOutlet var lblRatell: UILabel!
    @IBOutlet var lblExpll: UILabel!

    @IBOutlet var lblPracareall: UILabel!
}

构建时没有问题,但无法显示profileImages,这是我在输出窗口中出现的错误

2016-01-24 00:42:33.275 iLegaltwo[12534:831589] -[UITableViewCellContentView setImage:]: unrecognized selector sent to instance 0x7ffab8ee6760
2016-01-24 00:42:33.276 iLegaltwo[12534:831589] -[UITableViewCellContentView setImage:]: unrecognized selector sent to instance 0x7ffab8e87670
2016-01-24 00:42:33.276 iLegaltwo[12534:831589] -[UITableViewCellContentView setImage:]: unrecognized selector sent to instance 0x7ffab8ed3540
2016-01-24 00:42:33.277 iLegaltwo[12534:831589] -[UITableViewCellContentView setImage:]: unrecognized selector sent to instance 0x7ffab8ed2420

1 个答案:

答案 0 :(得分:0)

- [UITableViewCellContentView setImage:]:无法识别的选择器发送到实例

这就是说你试图对setImage:对象(没有这种方法)进行UITableViewCellContentView,而不是UIImageView({{1} })你写的时候:

imageDoctor

所以我猜,这似乎是因为您将doctorcell.imagedoctor.image = image imageDoctor)与IBOutlet的contentView而不是doctorsListCell相关联。