Ios 多个UiCollectionview重新加载问题
我以编程方式创建了多个UICollectionView,并且动态设置了值,效果良好。我只想立即更新3 UICollectionView。如何重新加载它 下面我附上了我的代码:Ios 多个UiCollectionview重新加载问题,ios,objective-c,xcode,uicollectionview,Ios,Objective C,Xcode,Uicollectionview,我以编程方式创建了多个UICollectionView,并且动态设置了值,效果良好。我只想立即更新3 UICollectionView。如何重新加载它 下面我附上了我的代码: for (int i=0; i<4; i++) { CGFloat x =0; CGFloat viewWidth = CGRectGetWidth(self.view.frame); UICollectionViewFlowLayout *layout=[[UICollectionViewF
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;
}
使用viewWithTag获取collectionView
UICollectionView *Collection = (UICollectionView *)[self.view viewWithTag:3];
然后,只需重新加载数据或执行以下操作:
[Collection reloadData];
请显示相关代码您已经通过编程创建了3个collectionview,您需要创建它的全局强对象。并使用reloadData方法重新加载集合viewcolview1.reloadData、colview2.reloadData、colview3.reloadData,即是;i@dahiya_boy我正在按程序创建。检查我的代码。