Reputation: 1
//collection view
UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
self.collectionView=[[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:layout];
[self.collectionView setDataSource:self];
[self.collectionView setDelegate:self];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
[self.collectionView setBackgroundColor:[UIColor redColor]];
[self.view addSubview:self.collectionView];
}
- (NSInteger)collectionView:(UICollectionView *)tcollectionView numberOfItemsInSection:(NSInteger)section
{
return 15;
}
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
cell.backgroundColor=[UIColor greenColor];
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(50, 50);
}
crash on :
-[NSISUnrestrictedVariable collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x7fce804111b0
What is that ? (the collection view is inside a view controller,tand he is inside a scrollview)
Upvotes: 0
Views: 296
Reputation: 1
Found the solution . As mentioned here, the collection view is deallocated from memory.
Reason is because that view controller that holds it, is inside a scrollview, and i didn't create it a property as strong to retain it , so :
//the view controller that holds the collection
@property(nonatomic,strong) BlisterView *blister;
solves the problem.
Upvotes: 0
Reputation: 9042
It looks like your UICollectionView
has been deallocated from memory but you are still trying to access it.
Enable NSZombies
and you'll see where you make the call to the deallocated memory and fix the code accordingly.
Upvotes: 1