ios18 崩溃2024-11-15

  • collection 滚动崩溃:

**** 崩溃代码:

   NSInteger lastY = 0;
        NSInteger section = MAX(self.firstArray.count-1, 0);
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:section];
        UICollectionReusableView *view = [self.collectionView.dataSource collectionView:self.collectionView viewForSupplementaryElementOfKind:UICollectionElementKindSectionHeader atIndexPath:indexPath];
        lastY = view.hq_y;
        
        UIEdgeInsets insets = self.collectionView.contentInset;
        insets.bottom = self.collectionView.hq_height - (self.collectionView.contentSize.height-lastY);
//        insets.left = 15;
        self.collectionView.contentInset = insets;

解决方法:collection 的回调方法之外不要试图去根据indexPath获取cell ,不过可以间接的去获取,比如下面的方法

        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:section];
        UICollectionViewLayoutAttributes *attributes = [_collectionView layoutAttributesForItemAtIndexPath:indexPath];
        lastY = attributes.frame.origin.y;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *面试心声:其实这些题本人都没怎么背,但是在上海 两周半 面了大约10家 收到差不多3个offer,总结起来就是把...
    Dove_iOS阅读 27,312评论 30 472
  • 1.ios高性能编程 (1).内层 最小的内层平均值和峰值(2).耗电量 高效的算法和数据结构(3).初始化时...
    欧辰_OSR阅读 29,797评论 8 265
  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 13,795评论 1 32
  • OC的理解与特性 OC作为一门面向对象的语言,自然具有面向对象的语言特性:封装、继承、多态。它既具有静态语言的特性...
    克鲁德李阅读 3,229评论 0 0
  • 序言 目前形势,参加到iOS队伍的人是越来越多,甚至已经到供过于求了。今年,找过工作人可能会更深刻地体会到今年的就...
    iOS_Alex阅读 5,494评论 1 24