【发布时间】:2017-09-25 06:02:12
【问题描述】:
我以编程方式创建了多个UICollectionView,并且我设置的值动态工作正常。我现在只想更新 3 UICollectionView。如何重新加载它。
下面我附上了我的代码:
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;
}
【问题讨论】:
-
请出示相关代码
-
您已经以编程方式创建了 3 个集合视图,您需要创建它的全局(强)对象。并使用 reloadData() 方法重新加载集合视图
-
colview1.reloadData(),colview2.reloadData(),colview3.reloadData(),就是这样。 -
for (int i=0; i
-
@dahiya_boy 我正在编程创建。检查我的代码。
标签: ios objective-c xcode uicollectionview