Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[UICollectionViewCell imageView]: unrecognized selector sent to instance

I am trying to use collection view and display static images in that, but I get the following error:

[UICollectionViewCell imageView]: unrecognized selector sent to instance.

I have configured 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 sscollectionViewCell.h code

@interface SSCollectionViewCell : UICollectionViewCell

@property (weak) IBOutlet UIImageView *imageView;

@end

here is the SSColletionViewCell.m code

#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 any one suggest where i made mistake.?

like image 530
Jatin Tamakuwala Avatar asked May 21 '26 09:05

Jatin Tamakuwala


1 Answers

Change

[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];

To

[self.collectionView registerClass:[SSCollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
like image 119
thatzprem Avatar answered May 22 '26 23:05

thatzprem