我使用UICollectionView
重新载入数据时遇到问题。我对viewDidLoad
这个数组填补了UICollectionView.
UICollectionView重新载入数据问题
array = [[NSMutableArray alloc] init];
[array addObject:@"1"];
[array addObject:@"2"];
[array addObject:@"3"];
[array addObject:@"4"];
[array addObject:@"5"];
[array addObject:@"6"];
和方法:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"Cell";
//cell = [[UICollectionViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
myCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 100, 20)];
[titleLabel setText:[array objectAtIndex:indexPath.row]];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.backgroundColor = [UIColor clearColor];
[cell addSubview:titleLabel];
return cell;
}
我挖掘UIButton
和数据重新加载:
[myCollectionView reloadData];
这里的数据如何外观就像重装前后一样:
请告诉我什么是“MyCell”,是否为 – Chandru 2014-10-01 07:13:52
还有什么更好的办法?你必须创建自定义单元格,以避免在uicollectionview中缓存数据 – TomSawyer 2014-10-24 13:54:14