Ios UICollectionView解除分配实例错误

Ios UICollectionView解除分配实例错误,ios,objective-c,ipad,ios6.1,Ios,Objective C,Ipad,Ios6.1,在我使用的UICollectionView中,cellForItemAtIndexPath工作正常,最初显示collectionView,即collectionView.reloadData第一次成功执行。 当使用以下代码重新加载时 [self.galleryCollectionView reloadData] 只需点击一个按钮,它就会崩溃。我已经启用了僵尸对象,它显示了错误 [CVCell release]: message sent to deallocated instance 0xa4

在我使用的UICollectionView中,cellForItemAtIndexPath工作正常,最初显示collectionView,即collectionView.reloadData第一次成功执行。 当使用以下代码重新加载时

[self.galleryCollectionView reloadData]
只需点击一个按钮,它就会崩溃。我已经启用了僵尸对象,它显示了错误

[CVCell release]: message sent to deallocated instance 0xa4f26c0.
下面是cellForItemAtIndexPath方法

-(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调用以下方法来创建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];
}
有什么建议吗?
提前感谢

在CreateCollectionView中,执行以下操作:

CVCell *cell = [UICollectionViewCell alloc] init];
[ self.galleryCollectionView registerClass:[CVCell class] forCellWithReuseIdentifier:@"myCell"];
[self.galleryCollectionView setDataSource:self];
然后,在cellForItemAtIndexPath中:

UICollectionViewCell *cell = [collView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];

我想这应该可以。但是我不确定你在哪里设置cell.delegate等。我不确定为什么会这样做,但我想这是可能的。

我无法解决问题,但我发现问题发生在数据源为空时,我通过添加一个空的不可见单元格绕过了错误!!!