Reputation: 86
I have created multiple UICollectionView
programmatically and I have set values dynamically working fine. I want update now 3 UICollectionView
only. How to reload it.
Below I attached my code:
for (int i=0; i<4; i++) {
CGFloat x =0;
CGFloat viewWidth = CGRectGetWidth(self.view.frame);
UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
collectionview =[[UICollectionView alloc] initWithFrame:CGRectMake(0,0, viewWidth, 160) collectionViewLayout:layout];
collectionview.backgroundColor=[UIColor clearColor];
collectionview.tag=i;
[collectionview setTag:i];
[collectionview registerNib:[UINib nibWithNibName:@“Cell” bundle:nil] forCellWithReuseIdentifier:@“Cell”];
collectionview.delegate=self;
collectionview.dataSource=self;
[self.view addSubview:collectionview];
x=x+viewWidth;
}
Upvotes: 0
Views: 421
Reputation: 3383
Get collectionView using viewWithTag.
UICollectionView *Collection = (UICollectionView *)[self.view viewWithTag:3];
Then, just reload the data or do whatever:
[Collection reloadData];
Upvotes: 1