我必须使用UITableViewCellStyle.Subtitle (因为它与PFTableViewCell配合得很好),我可以通过storyboard添加默认图像,其中有一个添加图像的选项。这工作得很好,但我想通过代码自己更新这个图像。我有以下代码:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! SBGestureTableViewCell!
if cell == nil {
cell = SBGestureTableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell")
}
// update cell image from default image to questionMark
cell.imageView?.image = UIImage(named: "Question_Mark@2x")
}但是,图像没有更新,我仍然看到默认图像。
发布于 2015-05-26 21:11:45
如果你使用的是png图片(因为你的图片名称包含@2x),你会错过.png。
如果您使用的是assets,请仔细检查资产中的名称。
此外,检查控制台,如果您没有正确的图像名称,它应该在那里输出它。
这就是我能从你的代码中得到的全部。
https://stackoverflow.com/questions/30459368
复制相似问题