2016-01-23 2 views
0

У меня следующий код //Непризнанный селектор отправляется, например, когда дисплей фотографии

// 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. 
    } 
    */ 

} 

EDIT

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 
+0

Можете ли вы добавить код класса "doctorListCell"? – Ryan

+0

Edit-ed с запрошенным классом – JackyBoi

+1

Убедитесь, что 'imagedoctor' правильно связан в Interface Builder (правильный компонент) – Larme

ответ

0

- [UITableViewCellContentView setImage]: непризнанные селектор направлен например

Это говорит, что вы пытаетесь сделать setImage: на UITableViewCellContentView объект (который не имеет этот метод), а не на UIImageView (imageDoctor), как вы написали:

doctorcell.imagedoctor.image = image 

так что я думаю, что, кажется, причина в том, что вы связаны imageDoctor (IBOutlet) к contentView из doctorsListCell вместо UIImageView.

Смежные вопросы