我使用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