ios libc abi.dylib:以 NSException CollectionView 类型的未捕获异常终止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25239766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 01:47:47  来源:igfitidea点击:

libc abi.dylib: terminating with uncaught exception of type NSException CollectionView

iosobjective-cnsexception

提问by Luca Briganti

when i run my app, i received this error :

当我运行我的应用程序时,我收到此错误:

2014-08-11 10:52:10.546 ControlViewTest[918:60b] -[UIViewController collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x8c862f0
2014-08-11 10:52:10.605 ControlViewTest[918:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x8c862f0'
* First throw call stack:
(
    0   CoreFoundation                      0x017ec1e4 exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0156b8e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01889243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x017dc50b ___forwarding_ + 1019
    4   CoreFoundation                      0x017dc0ee _CF_forwarding_prep_0 + 14
    5   UIKit                               0x008b0c34 -[UICollectionViewData _updateItemCounts] + 331
    6   UIKit                               0x008b0ce1 -[UICollectionViewData _validateItemCounts] + 45
    7   UIKit                               0x008b2c64 -[UICollectionViewData numberOfSections] + 35
    8   UIKit                               0x0087d6ed -[UICollectionView numberOfSections] + 62
    9   UIKit                               0x0089d614 -[UICollectionViewFlowLayout(Internal) _getSizingInfos] + 205
    10  UIKit                               0x0089e48f -[UICollectionViewFlowLayout(Internal) _fetchItemsInfo] + 521
    11  UIKit                               0x00899fe2 -[UICollectionViewFlowLayout prepareLayout] + 157
    12  UIKit                               0x008b0d9d -[UICollectionViewData _prepareToLoadData] + 76
    13  UIKit                               0x008b15c5 -[UICollectionViewData validateLayoutInRect:] + 56
    14  UIKit                               0x00877603 -[UICollectionView layoutSubviews] + 173
    15  UIKit                               0x0029a964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    16  libobjc.A.dylib                     0x0157d82b -[NSObject performSelector:withObject:] + 70
    17  QuartzCore                          0x03c5745a -[CALayer layoutSublayers] + 148
    18  QuartzCore                          0x03c4b244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    19  QuartzCore                          0x03c573a5 -[CALayer layoutIfNeeded] + 160
    20  UIKit                               0x0035cae3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
    21  UIKit                               0x00272aa7 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
    22  UIKit                               0x00271646 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
    23  UIKit                               0x00271518 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
    24  UIKit                               0x002715a0 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
    25  UIKit                               0x0027063a 57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
    26  UIKit                               0x0027059c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
    27  UIKit                               0x002712f3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
    28  UIKit                               0x002748e6 -[UIWindow setDelegate:] + 449
    29  UIKit                               0x0034eb77 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
    30  UIKit                               0x0026a474 -[UIWindow addRootViewControllerViewIfPossible] + 591
    31  UIKit                               0x0026a5ef -[UIWindow _setHidden:forced:] + 312
    32  UIKit                               0x0026a86b -[UIWindow _orderFrontWithoutMakingKey] + 49
    33  UIKit                               0x002753c8 -[UIWindow makeKeyAndVisible] + 65
    34  UIKit                               0x00225bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
    35  UIKit                               0x0022a667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
    36  UIKit                               0x0023ef92 -[UIApplication handleEvent:withNewEvent:] + 3517
    37  UIKit                               0x0023f555 -[UIApplication sendEvent:] + 85
    38  UIKit                               0x0022c250 _UIApplicationHandleEvent + 683
    39  GraphicsServices                    0x037e1f02 _PurpleEventCallback + 776
    40  GraphicsServices                    0x037e1a0d PurpleEventCallback + 46
    41  CoreFoundation                      0x01767ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 53
    42  CoreFoundation                      0x017679db __CFRunLoopDoSource1 + 523
    43  CoreFoundation                      0x0179268c __CFRunLoopRun + 2156
    44  CoreFoundation                      0x017919d3 CFRunLoopRunSpecific + 467
    45  CoreFoundation                      0x017917eb CFRunLoopRunInMode + 123
    46  UIKit                               0x00229d9c -[UIApplication _run] + 840
    47  UIKit                               0x0022bf9b UIApplicationMain + 1225
    48  ControlViewTest                     0x0000264d main + 141
    49  libdyld.dylib                       0x01e33701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)



有人可以帮我请

回答by DarkDust

Your UICollectionViewhas a data source set which does not implement the requiredmethod collectionView:numberOfItemsInSection:. You need to assign your UICollectionViewa valid data source: a class that you've written and that implements collectionView:numberOfItemsInSection:.

UICollectionView有一个未实现所需方法的数据源集collectionView:numberOfItemsInSection:。您需要分配UICollectionView一个有效的数据源:您编写并实现collectionView:numberOfItemsInSection:.