我在视图中添加了一个UICollectionView,我实现了下面的方法。
我得到错误:
"NSInvalidArgumentException',原因:'-NSIndexPath reuseIdentifier:未识别的选择器发送到实例‘“
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 1;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"CellID";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
UIImageView *imageView = (UIImageView *)[cell viewWithTag:10];
imageView.image = [UIImage imageNamed:@"V.jpg"];
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}发布于 2013-03-01 08:02:12
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"CellID";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
UIImageView *imageView = (UIImageView *)[cell viewWithTag:10];
imageView.image = [UIImage imageNamed:@"V.jpg"];
return cell; // here is ur mistake
}将return cell;添加到末尾。
发布于 2014-04-04 03:02:27
细胞需要注册到CollectionView之前,
[self.dateCollectionView registerClass:[DateCell Class] forCellWithReuseIdentifier:identifier];见标识符
https://stackoverflow.com/questions/15153063
复制相似问题