CollectionViewCell崩溃

collectionViewCell内只放了一个Label致使崩溃,全局断点无法拦截,只能看到控制台崩溃

image.png
*** Assertion failure in -[_UIUpdateVisibleCellsContext addPreferredAttributes:], UICollectionViewLayout.m:2914
dynamic_cast error 2: One or more of the following type_info's has hidden visibility or is defined in more than one translation unit. They should all have public visibility. N10__cxxabiv116__shim_type_infoE, id, N10__cxxabiv117__pbase_type_infoE.
dynamic_cast error 2: One or more of the following type_info's has hidden visibility or is defined in more than one translation unit. They should all have public visibility. N10__cxxabiv116__shim_type_infoE, id, N10__cxxabiv117__pbase_type_infoE.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !CGSizeEqualToSize(size, CGSizeZero)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007ff8004288ab __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff80004dba3 objc_exception_throw + 48
    2   Foundation                          0x00007ff800b870cc _userInfoForFileAndLine + 0
    3   UIKitCore                           0x000000010b9c9501 -[_UIUpdateVisibleCellsContext addPreferredAttributes:] + 527
    4   UIKitCore                           0x000000010b9b7908 -[UICollectionViewFlowLayout shouldInvalidateLayoutForPreferredLayoutAttributes:withOriginalAttributes:] + 351
    5   UIKitCore                           0x000000010b95566b -[UICollectionView _checkForPreferredAttributesInView:originalAttributes:] + 489
    6   UIKitCore                           0x000000010b956de6 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 1711
    7   UIKitCore                           0x000000010b956731 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 31
    8   UIKitCore                           0x000000010b960d47 -[UICollectionView _createVisibleViewsForSingleCategoryAttributes:limitCreation:fadeForBoundsChange:] + 1731
    9   UIKitCore                           0x000000010b96124b -[UICollectionView _createVisibleViewsForAttributes:fadeForBoundsChange:notifyLayoutForVisibleCellsPass:] + 376
    10  UIKitCore                           0x000000010b95efad -[UICollectionView _updateVisibleCellsNow:] + 2331
    11  UIKitCore                           0x000000010b965bc4 -[UICollectionView layoutSubviews] + 375
    12  UIKitCore                           0x000000010ca8f59f -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2305
    13  QuartzCore                          0x00007ff80898b02c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 526
    14  QuartzCore                          0x00007ff8089965b9 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 65
    15  QuartzCore                          0x00007ff8088a7b0c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 626
    16  QuartzCore                          0x00007ff8088df69b _ZN2CA11Transaction6commitEv + 735
    17  QuartzCore                          0x00007ff8088e0b64 _ZN2CA11Transaction25flush_as_runloop_observerEb + 60
    18  CoreFoundation                      0x00007ff800387055 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    19  CoreFoundation                      0x00007ff8003819c2 __CFRunLoopDoObservers + 515
    20  CoreFoundation                      0x00007ff800381f0d __CFRunLoopRun + 1161
    21  CoreFoundation                      0x00007ff8003816a7 CFRunLoopRunSpecific + 560
    22  GraphicsServices                    0x00007ff809cb128a GSEventRunModal + 139
    23  UIKitCore                           0x000000010c45cad3 -[UIApplication _run] + 994
    24  UIKitCore                           0x000000010c4619ef UIApplicationMain + 123
    25  CaiFuBang                           0x0000000109575c18 main + 104
    26  dyld                                0x000000010ab102bf start_sim + 10
    27  ???                                 0x000000010ef57310 0x0 + 4545934096
)
2023-08-16 09:55:32.619077+0800 CaiFuBang[73323:19785329] [Bugly]  Trapped uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !CGSizeEqualToSize(size, CGSizeZero)' 
(
    0   CoreFoundation                      0x00007ff8004288ab __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff80004dba3 objc_exception_throw + 48
    2   Foundation                          0x00007ff800b870cc _userInfoForFileAndLine + 0
    3   UIKitCore                           0x000000010b9c9501 -[_UIUpdateVisibleCellsContext addPreferredAttributes:] + 527
    4   UIKitCore                           0x000000010b9b7908 -[UICollectionViewFlowLayout shouldInvalidateLayoutForPreferredLayoutAttributes:withOriginalAttributes:] + 351
    5   UIKitCore                           0x000000010b95566b -[UICollectionView _checkForPreferredAttributesInView:originalAttributes:] + 489
    6   UIKitCore                           0x000000010b956de6 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 1711
    7   UIKitCore                           0x000000010b956731 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 31
    8   UIKitCore                           0x000000010b960d47 -[UICollectionView _createVisibleViewsForSingleCategoryAttributes:limitCreation:fadeForBoundsChange:] + 1731
    9   UIKitCore                           0x000000010b96124b -[UICollectionView _createVisibleViewsForAttributes:fadeForBoundsChange:notifyLayoutForVisibleCellsPass:] + 376
    10  UIKitCore                           0x000000010b95efad -[UICollectionView _updateVisibleCellsNow:] + 2331
    11  UIKitCore                           0x000000010b965bc4 -[UICollectionView layoutSubviews] + 375
    12  UIKitCore                           0x000000010ca8f59f -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2305
    13  QuartzCore                          0x00007ff80898b02c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 526
    14  QuartzCore                          0x00007ff8089965b9 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 65
    15  QuartzCore                          0x00007ff8088a7b0c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 626
    16  QuartzCore                          0x00007ff8088df69b _ZN2CA11Transaction6commitEv + 735
    17  QuartzCore                          0x00007ff8088e0b64 _ZN2CA11Transaction25flush_as_runloop_observerEb + 60
    18  CoreFoundation                      0x00007ff800387055 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    19  CoreFoundation                      0x00007ff8003819c2 __CFRunLoopDoObservers + 515
    20  CoreFoundation                      0x00007ff800381f0d __CFRunLoopRun + 1161
    21  CoreFoundation                      0x00007ff8003816a7 CFRunLoopRunSpecific + 560
    22  GraphicsServices                    0x00007ff809cb128a GSEventRunModal + 139
    23  UIKitCore                           0x000000010c45cad3 -[UIApplication _run] + 994
    24  UIKitCore                           0x000000010c4619ef UIApplicationMain + 123
    25  CaiFuBang                           0x0000000109575c18 main + 104
    26  dyld                                0x000000010ab102bf start_sim + 10
    27  ???                                 0x000000010ef57310 0x0 + 4545934096
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !CGSizeEqualToSize(size, CGSizeZero)'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPhone 14 Pro (FC0C4325-685D-4CB2-8B18-A23F8EA22CC6) - Runtime: iOS 16.2 (20C52) - DeviceType: iPhone 14 Pro

产生原因:

image.png

storyboard拖的collectionView 默认预估大小自动计算,解决办法设置none

解决办法:

image.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 13,868评论 1 32
  • 用到的组件 1、通过CocoaPods安装 2、第三方类库安装 3、第三方服务 友盟社会化分享组件 友盟用户反馈 ...
    SunnyLeong阅读 14,962评论 1 180
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,378评论 4 61
  • 1.ios高性能编程 (1).内层 最小的内层平均值和峰值(2).耗电量 高效的算法和数据结构(3).初始化时...
    欧辰_OSR阅读 29,923评论 8 265
  • 声明:面试是对自我审视的一种过程,面试题和iOS程序员本身技术水平没有对等关联,无论你能否全部答出,都不要对自己产...
    Kevin_wzx阅读 6,648评论 1 2

友情链接更多精彩内容