我有一個UIImageViews
的數組,我想要在屏幕上顯示。但是,我似乎無法做到這一點。我宣佈我的UIImageViews
陣列像這樣:UIImageView Array未顯示內容?
class EventCell: UITableViewCell, CellDelegate{
@IBOutlet var eventName: UILabel!
@IBOutlet var eventLocation: UILabel!
@IBOutlet var attendeesImages: [UIImageView]!
}
而且我有一個顯示的EventCell
內容像這樣的功能:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//Dequeue a "reusable" cell
let cell = tableView.dequeueReusableCellWithIdentifier(eventCellIdentifier) as! EventCell
setCellContents(cell, indexPath: indexPath)
return cell
}
//Set contents of Event Cell.. self.events is a global array
//which have information that EventCell objects need to display
func setCellContents(cell:EventCell, indexPath: NSIndexPath!){
let item = self.events[indexPath.section]
var count = 0
cell.eventName.text = item.eventName()
cell.eventLocation.text = item.eventLocation()
cell.attendeesImage.removeAll(keepCapacity: false)//Remove old images before adding new
for value in item.attendeesImage {
let newImageView = UIImageView(image : value)
newImageView.clipsToBounds = true
newImageView.layer.cornerRadius = newImageView.frame.size.width/2
cell.attendeesImage.append(newImageView)
println("Count inside: \(cell.attendeesImage.count)")
}
}
我打印出來的cell.attendeesImage
的count
,以確保沒有多餘的圖片正在被添加,它似乎證明是正確的。但是,我不知道爲什麼我的圖像不顯示。我確定在EventCell
中將cell.attendeesImage
作爲IBCollection掛在我的Storyboard中(因爲它是一個Array)。任何想法爲什麼這不顯示?謝謝!
如何在你的表格視圖單元格中佈置圖像? – ozgur
@ozgur那一步我還沒有完成,我也不完全確定如何做這部分。在我解決這個問題之後,我正在研究它。有什麼建議麼? – user1871869
如果你還沒有實現那部分,那麼我不太明白你的問題是什麼。代碼負責在你的單元格中顯示圖像在哪裏?您是否檢查過像cell.contentView.addSubview(newImageView)' – ozgur