View collection inside cell reload data table

I have a UICollectionView inside a UITableViewCell and the images for the collection view are pulled from parsing on a background thread. The problem I am facing is that I cannot call the reloadData of the collection because I cannot set the UICollectionView property as it is inside the table view cell. Any idea on how to reload the collection view data after the background thread has finished executing the request?

+3


source to share


1 answer


Subclass UITableViewCell and add methods and reference to its collection view. Handle your calls. I am assuming that you have created a collection view on your table view controller.

eg.

CollectionViewTableCell.h:

@interface CollectionViewTableCell : UITableViewCell
@end

      



CollectionViewTableCell.m:

@interface CollectionViewTableCell ()
    @property (nonatomic, weak) @IBOutlet UICollectionView* collectionView;
@end

@implementation CollectionViewTableCell
-(void) awakeFromNib {
    [self loadData];
}
-(void) loadData {
    // load parse data asynchronously and then call reloadData on your collection view
}

 // make sure to implement delegate/datasource methods for your collection view
@end

      

Note that there are ways to just send the url of the image to the UIImageView and the images will load asynchronously from the url (for example AFNetworking has a category that supports this).

0


source







All Articles