here's my code :
- (void)viewDidLoad {
[super viewDidLoad];
...
UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
[layout setItemSize:CGSizeMake(160, 160)];
[layout setMinimumInteritemSpacing:5.f];
[layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
_photoPicker = [[UICollectionView alloc] initWithFrame:CGRectMake(10, 10 , self.view.frame.size.width - 20, 160 ) collectionViewLayout:layout];
[_photoPicker registerNib:[UINib nibWithNibName:@"photoUploadCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@" photoUploadCell"];
//[_photoPicker registerClass:[photoUploadCollectionViewCell class] forCellWithReuseIdentifier:@"photoUploadCell"];
_photoPicker.backgroundColor = gray;
_photoPicker.delegate = self;
_photoPicker.dataSource = self;
[self.scrollView addSubview:_photoPicker];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
photoUploadCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"photoUploadCell" forIndexPath:indexPath];
}
This code crash at photoUploadCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"photoCell" forIndexPath:indexPath];
and I get this error :
2015-05-26 10:45:29.363 Free Sale[4505:55482] * Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /SourceCache/UIKit_Sim/UIKit-3347.44/UICollectionView.m:3454 2015-05-26 10:45:29.374 Free Sale[4505:55482] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier photoCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' *** First throw call stack:
Any one know this wired issue ?
photoCell
is not registered.. is this the actual code you have? because you have a white spaceforCellWithReuseIdentifier:
.. – 0yeoj