static NSString *identifier=@"cell";
- (void)viewDidLoad {
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets=NO;//去掉顶部留白
//注册cell 有几种cell样式注册几次
[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:identifier];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
//在这里注册自定义的XIBcell否则会提示找不到标示符指定的cell
UINib *nib = [UINibnibWithNibName:@"FCollectionViewCell"bundle: [NSBundlemainBundle]];
[collectionView registerNib:nib forCellWithReuseIdentifier:identifier];
FCollectionViewCell *cell = [collectionViewdequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
return cell;
}