【问题标题】:libc++abi.dylib: terminating with uncaught exception of type NSException (CollectionView)libc++abi.dylib:以 NSException (CollectionView) 类型的未捕获异常终止
【发布时间】:2016-06-20 19:07:23
【问题描述】:

当我使用 CollectionView 启动我的应用程序时:

2016-06-20 20:37:30.640 Projekt A[19055:699202] -[UIViewController collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x7fd1bbfa3ac0
2016-06-20 20:37:30.748 Projekt A[19055:699202] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x7fd1bbfa3ac0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010f8d2d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000111854deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010f8dbd3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010f821cfa ___forwarding___ + 970
    4   CoreFoundation                      0x000000010f8218a8 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x0000000110baa56c -[UICollectionViewData _updateItemCounts] + 492
    6   UIKit                               0x0000000110bad009 -[UICollectionViewData numberOfSections] + 22
    7   UIKit                               0x0000000110b8ef51 -[UICollectionViewFlowLayout _getSizingInfos] + 445
    8   UIKit                               0x0000000110b90c47 -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 118
    9   UIKit                               0x0000000110b8a3fd -[UICollectionViewFlowLayout prepareLayout] + 273
    10  UIKit                               0x0000000110baac3d -[UICollectionViewData _prepareToLoadData] + 67
    11  UIKit                               0x0000000110bab411 -[UICollectionViewData validateLayoutInRect:] + 53
    12  UIKit                               0x0000000110b5853a -[UICollectionView layoutSubviews] + 199
    13  UIKit                               0x0000000110393980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
    14  QuartzCore                          0x0000000114a4ac00 -[CALayer layoutSublayers] + 146
    15  QuartzCore                          0x0000000114a3f08e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    16  QuartzCore                          0x0000000114a3ef0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    17  QuartzCore                          0x0000000114a333c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
    18  QuartzCore                          0x0000000114a61086 _ZN2CA11Transaction6commitEv + 486
    19  UIKit                               0x000000011030519b _afterCACommitHandler + 174
    20  CoreFoundation                      0x000000010f7f7c37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    21  CoreFoundation                      0x000000010f7f7ba7 __CFRunLoopDoObservers + 391
    22  CoreFoundation                      0x000000010f7ed7fb __CFRunLoopRun + 1147
    23  CoreFoundation                      0x000000010f7ed0f8 CFRunLoopRunSpecific + 488
    24  GraphicsServices                    0x000000011607cad2 GSEventRunModal + 161
    25  UIKit                               0x00000001102d8f09 UIApplicationMain + 171
    26  Projekt A                           0x000000010f6e4292 main + 114
    27  libdyld.dylib                       0x000000011238292d start + 1
    28  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 有人可以帮我吗? ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

【问题讨论】:

  • 你的视图控制器实现了这个方法[collectionView:numberOfItemsInSection:]?

标签: ios xcode swift uicollectionview uicollectionviewcell


【解决方案1】:

错误是说集合视图的数据源设置为普通的UIViewController,而不是您拥有的任何实现UICollectionViewDataSource 的类。

检查您的数据源是如何分配的以及它是什么类别的对象。

【讨论】:

  • 哦,好的,我找到了。谢谢
猜你喜欢
  • 2014-10-04
  • 2015-09-08
  • 1970-01-01
  • 2014-12-14
  • 2017-05-25
  • 1970-01-01
  • 1970-01-01
  • 2017-02-06
  • 2018-12-11
相关资源
最近更新 更多