[UICollectionViewCell imageView]: unrecognized selector posted to instance
I am trying to use a collection view and display static images in it, but I am getting the following error:
[UICollectionViewCell imageView]: unrecognized selector posted to the instance.
I configured the cell identifire = Cell
.
Here is my code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
SSCollectionViewCell *cell = (SSCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
int imageNumber = indexPath.row % 10;
cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"Image%d.jpg",imageNumber]];
return cell;
}
here is the code sscollectionViewCell.h
@interface SSCollectionViewCell : UICollectionViewCell
@property (weak) IBOutlet UIImageView *imageView;
@end
here is the code SSColletionViewCell.m
#import "SSCollectionViewCell.h"
@interface SSCollectionViewCell ()
@end
@implementation SSCollectionViewCell
@synthesize imageView;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
@end
Can anyone suggest where I went wrong.?
+3
source to share
3 answers