After
I am downloading some pictures and putting them in my UICollectionView
These are my class members
var myItems: [UIImage] = [] var myView: UICollectionView?
I have a timer function that receives IMG: UIImage object. I have included the count on this in my UICollectionView like this
self.myItems.insert (img, atIndex: self.myItems.count): int? = Index on Self.myView .numberOfItemsInSection (0):? NSIndexPath = NSIndexPath (forRow: count !, insection: 0)? Self.myView .insertItemsAtIndexPaths ([index])
I also have this function:
function collectionView (collectionView: UICollectionView, numberOfItemsInSection section: Int) - & Gt; Int {Returns Self. Coat; }
and this one:
function collectionView (collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) - & gt; UICollectionViewCell {cell = collectionView.dequeueReusableCellWithReuseIdentifier ("cell", ForIndexPath: indexPath) MyCollectionViewCell as cell. Background color = UIColor.orangeColor () cell.textLabel.text = "Text \ (indexPath.row)" cell.imageView.image = myItems [indexPath.row] cell.backgroundView = UIImageView (Image: UIImage (name: "cellbg" )) Return Cell}
However my thoughts do not show new images immediately. I have to tap on the blank screen, then the new cell appears with my image, besides, I can not scroll the view if there are as many cells that fit into the scene.
How do I refresh the scene? Am I dacking cell, is there anything wrong with this?
You forgot to reload UICollectionView
.
self.myView.reloadData ()
No comments:
Post a Comment