ios - 修复导致 sigabort

标签 ios uicollectionview uicollectionviewcell

我在我的代码中将其更改为 descriptionLabel,我认为它不是保留关键字,但仍然将其称为 descriptionLabel 会好得多。

编译器没有混淆,这确实是一个合乎逻辑的解释。

现在的代码是:

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{    
      RhythmCell *cell = (RhythmCell *)[cv dequeueReusableCellWithReuseIdentifier:@"RhythmCell" forIndexPath:indexPath];

      UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(5, 20, cell.bounds.size.width-10, cell.bounds.size.height+150)];
      title.font = [UIFont systemFontOfSize:15];
      title.tag = indexPath.row;
      title.numberOfLines = 2;
      title.textAlignment = NSTextAlignmentCenter;

      title.text = cell.descriptionLabel.text;
      [cell.contentView addSubview:title];

      return cell;
 }

最佳答案

不要称某些东西为description。这是 NSObject 上的一个现有方法,它返回一个字符串。崩溃看起来就是您要返回的内容,因为您要为 text 属性请求一个字符串。

您可能没有取回正确类别的单元格,或者您没有正确实现描述,但这很难从问题中判断出来。

关于ios - 修复导致 sigabort,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24285022/

相关文章:

ios - 无法同时录制/播放 AudioQueue 和动画

ios - 如何通过 OutputStream 发送 NSData

ios - MvvmCross - Root View Controller

swift - CollectionView 中的 CollectionView : Using didSelectItemAt to performSegue

ios - Collection View 单元格中的图像不正确

ios - 如何以编程方式获取 iOS 上粘贴板内容的来源

swift - 从 UICollectionView 中删除项目后更新/重新加载 Collection View

ios - 如何将 rbcollectionviewinfofolderlayout 与自定义 UICollectionViewCell 和 CollectionViewLayout 一起使用

ios - 如何滚动另一个 UICollectionView 下方的 UICollectionView?

iOS:设置 UICollectionView 单元格以查看大小