我在我的代码中将其更改为 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/