我在扩展程序中使用Swift 2和XCode 7.2。我正在使用包含图像和标签的单元格渲染UITableView,问题是图像是隐藏的!我不知道为什么!请有人帮帮我吗
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel!.textColor = UIColor.whiteColor()
let query = PFQuery(className:"Recipe")
query.orderByDescending("createdAt")
query.findObjectsInBackgroundWithBlock {
(objects: [PFObject]?, error: NSError?) -> Void in
if error == nil {
print("Success retrieved \(objects!.count) scores.")
if let objects = objects {
for object in objects {
let a:String = object.objectForKey("title") as! String
self.contentString.append(a)
}
}
let cellImg : UIImageView = UIImageView(frame: CGRectMake(5, 5, 50, 50))
cellImg.backgroundColor=UIColor.whiteColor()
cellImg.image = UIImage(named: "jj.png")
// cell.addSubview(cellImg)
cell.imageView!.image=cellImg.image
cell.textLabel!.text = self.contentString[indexPath.row]
}}
return cell
}