美文网首页IT@程序员猿媛iOS bug修复
[UICollectionView _createPrepare

[UICollectionView _createPrepare

作者: LiYaoPeng | 来源:发表于2019-04-17 12:12 被阅读6次

崩溃日止为: [UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 364

一般为- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
方法中出现了崩溃
**原因: **
1. 返回的cell为nil
查看有没有注册cell
2. 如果崩溃日志中 有[__NSCFArray count]或者腾讯bugly中有 -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray提示

  1. 查看cellForItemAtIndexPath方法中是否有数组越界的可能
  2. 查看[collectionView reloadData] 的时机是否正确,可能数据源变化后,没有进行reloadData,如果这时候滑动列表页,就有可能会导致崩溃。

相关文章

网友评论

    本文标题:[UICollectionView _createPrepare

    本文链接:https://www.haomeiwen.com/subject/kjwgwqtx.html