1
UIImageView
未在我的自定義UITableViewCell
中顯示圖像。UIImageView未在自定義UITableViewCell中顯示圖像
想不通爲什麼,我已經嘗試設置Image
特性它在Interface Builder
這兩種方法,然後試圖建立一個IBOutlet
並設置.image
財產。
似乎沒有工作。爲什麼這發生在我身上?!?!
類具有TableViewDataSource
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("LatestMessageCell") as LatestMessageCell
cell.avatarImageView.image = UIImage(named: "Logo")
return cell
}
自定義單元格類
class LatestMessageCell: UITableViewCell {
@IBOutlet weak var cardBackgroundView: UIView!
@IBOutlet weak var avatarImageView: UIImageView!
@IBOutlet weak var usernameLabel: UILabel!
@IBOutlet weak var messageLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
cardBackgroundView.layer.cornerRadius = 4
cardBackgroundView.layer.shadowColor = UIColor.blackColor().CGColor
cardBackgroundView.layer.shadowOffset = CGSize(width: 0, height: 2)
cardBackgroundView.layer.shadowOpacity = 0.3
cardBackgroundView.layer.shadowRadius = 5
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
我會說: •檢查插座是否設置正確 •檢查圖像是否已加載(可能是錯誤的圖像名稱?) – DeFrenZ 2014-11-21 12:12:14