In the UICollectionView which i use,cellForItemAtIndexPath works perfectly and displays the collectionView initially.That is collectionView.reloadData executes succesfully the first time. When it is reloaded with the following code
[self.galleryCollectionView reloadData]
with the click of a button it ends up in crash. I have enabled the Zombie objects and it shows the error
[CVCell release]: message sent to deallocated instance 0xa4f26c0.
Following is the cellForItemAtIndexPath Method
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionVieww cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"myCell";
CVCell *cell = (CVCell *)[collectionVieww dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
cell.cellid=indexPath;
cell.delegate=self;
cell.containerImage.delegate=self;
return cell;
}
my ViewDidLoad calls the following method to create the collectionView.
-(void) createCollectionView
{
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
//This is the size of a single cell courtesy:varuns research.
[flowLayout setItemSize:CGSizeMake(179, 224)];
flowLayout.minimumInteritemSpacing=45;
flowLayout.minimumLineSpacing=100;
flowLayout.sectionInset = UIEdgeInsetsMake(20, 30, 20, 5);
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
self.galleryCollectionView=[[UICollectionView alloc] initWithFrame:CGRectMake(0, 45, self.view.frame.size.width, self.view.frame.size.height-120) collectionViewLayout:flowLayout];
[ self.galleryCollectionView registerClass:[CVCell class] forCellWithReuseIdentifier:@"myCell"];
[self.galleryCollectionView setDataSource:self];
[self.galleryCollectionView setDelegate:self];
self.galleryCollectionView.backgroundColor=[UIColor clearColor];
[self.view addSubview:self.galleryCollectionView];
[self.galleryCollectionView reloadData];
}
Any workaround to suggest? Thanks in Advance