mardi 5 mai 2015

Feeding dynamic data to UICollectionView within UITableViewCell

Hello friendly swifters.

I am generating a table of cells.
each cell contains 2 labels, 1 button, 1 collectionview
each collectionview will display a collection of images

I can get my dynamic data to update the labels and buttons as needed.

I could use some help getting the collectionview cell to show my images. The collectionview prototype does have an imageview within it, which is linked to my collectionviewcell class.

example of empty collection views:
enter image description here

here's some code:

//My TableView 'cellForRowAtIndexPath

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell:DeckTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell2", forIndexPath: indexPath) as! DeckTableViewCell

    let deck:PFObject = timeLineData.objectAtIndex(indexPath.row) as! PFObject

    let sequenceTemp = deck.objectForKey("Sequence") as! String

    cell.sequenceId.setTitle(deck.objectId, forState: UIControlState.Normal)
    cell.cardCountLabel.text = "\((count(sequenceTemp)/2))"

    var dateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "(MM-dd) hh:mm:ss"
    cell.timeLabel.text = dateFormatter.stringFromDate(deck.updatedAt!)

    return cell
}


let images = ["2C.png", "3C.png", "4C.png", "5C.png", "6C.png", "7C.png", "8C.png", "9C.png", "10C.png", "JC.png", "QC.png", "KC.png", "AC.png"]

//My CollectionView 'cellForItemAtIndexPath

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    let cell: TableCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! TableCollectionViewCell

    let image = UIImage(named: images[indexPath.row])

    cell.ImageView.image = image
    cell.ImageView.backgroundColor = UIColor.orangeColor()

    return cell
}

The collectionview cell is not updating, not even to orange.

thanks for your time.

Aucun commentaire:

Enregistrer un commentaire