小编use*_*524的帖子

UICollectionView:发送到实例的无法识别的选择器

我收到了这个错误. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewCell label]: unrecognized selector sent to instance 0x1eead660'我正在使用一个nib文件作为我的单元格并尝试正确显示单元格.我猜我没有正确地返回细胞,但我不太确定.任何帮助将不胜感激.

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView    cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell";
    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
    Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];

    NSMutableArray *data = [sections objectAtIndex:indexPath.section];

    cell.label.text = [data objectAtIndex:indexPath.item];

    return cell;
 }
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios

4
推荐指数
1
解决办法
6852
查看次数

标签 统计

ios ×1

objective-c ×1

xcode ×1