NSrangeException导致接口构建器行动怪异

发布于 2025-01-27 21:46:34 字数 6292 浏览 6 评论 0原文

我的“ main.storyboard”文件有问题。我正在使用Xcode 13.3.1。这是接口构建器的图像:

”“在此处输入图像描述”

如您所见,视图控制器之一仅显示其子视图的边界。

这是我单击“报告错误”时收到的“ log.txt”文件:

    ASSERTION:
=================================

Failed to update scene 'WYl-z5-IOU' with IBLayoutConstraint (x181), IBUIViewAutolayoutGuide (x1), UIButton (x12), UICollectionView (x3), UICollectionViewCell (x3), UICollectionViewFlowLayout (x3), UIImageView (x8), UILabel (x20), UIPageControl (x1), UIScrollView (x1), UIStackView (x10), UITextField (x1), UIView (x18), and UIViewController (x1).

Exception name: NSRangeException
Exception reason: *** -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array
Exception backtrace: 
  0. CoreFoundation           0x00007fff20406d34 __exceptionPreprocess
  1. libobjc.A.dylib          0x00007fff201a4a65 objc_exception_throw
  2. CoreFoundation           0x00007fff20487f47 _CFThrowFormattedException
  3. CoreFoundation           0x00007fff203016b2 -[__NSArrayM objectAtIndexedSubscript:]
  4. UIKitCore                0x00007fff247448bc -[_UIFlowLayoutSection computeLayoutInRect:forSection:invalidating:invalidationContext:]
  5. UIKitCore                0x00007fff24728a75 __76-[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:]_block_invoke
  6. CoreFoundation           0x00007fff2037682c __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__
  7. CoreFoundation           0x00007fff203009c6 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:]
  8. UIKitCore                0x00007fff2472871d -[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:]
  9. UIKitCore                0x00007fff24728cee -[UICollectionViewFlowLayout _fetchItemsInfoForRect:]
 10. UIKitCore                0x00007fff24721950 -[UICollectionViewFlowLayout prepareLayout]
 11. UIKitCore                0x00007fff2471b450 -[UICollectionViewData _prepareToLoadData]
 12. UIKitCore                0x00007fff2471c2b5 -[UICollectionViewData validateLayoutInRect:]
 13. UIKitCore                0x00007fff246db9f1 -[UICollectionView layoutSubviews]
 14. UIKitCore                0x00007fff2565a2b0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
 15. QuartzCore               0x00007fff28a6639d _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE
 16. UIKitCore                0x00007fff256457fa -[UIView(Hierarchy) layoutBelowIfNeeded]
 17. IBCocoaTouchToolFoundation 0x000000010832fa2d -[IBCocoaTouchToolAutolayoutEngine layoutIfNeeded]
 18. IBAutolayoutFoundation   0x000000010847f736 __54-[IBAutolayoutEngine initWithArbitrationUnit:options:]_block_invoke.46
 19. CoreAutoLayout           0x00007fff60b03f05 -[NSISEngine performModifications:withUnsatisfiableConstraintsHandler:]
 20. IBAutolayoutFoundation   0x000000010848df03 -[NSObject(IBAutolayoutFrameworkSupportInternal) ib_performModifications:withUnsatisfiableConstraintsHandler:]
 21. IBAutolayoutFoundation   0x000000010847fbc8 -[IBAutolayoutEngine performInternalEngineModificationsAndAssertOnUnsatisfiableConstraintsIfNeededDuring:withUnsatisfiableConstraintsHandler:]
 22. IBAutolayoutFoundation   0x0000000108483915 -[IBAutolayoutEngine continuouslyPerformEngineBootstrappingOperationWithName:untilSuccessWhileTrackingUnsatisfiableConstraintsDuring:withUnsatisfiableConstraintRemovedHandler:]
 23. IBAutolayoutFoundation   0x000000010847f58b -[IBAutolayoutEngine initWithArbitrationUnit:options:]
 24. IBAutolayoutFoundation   0x000000010846eb72 -[IBAutolayoutArbitrationUnit computeStatus]
 25. IBCocoaTouchToolFoundation 0x000000010834cdb0 -[IBAutolayoutStatusProcessingRequest(IBCTTSupport) produceResultForRequest:simulatedMetricsContext:scaleFactor:tool:]
 26. IBCocoaTouchToolFoundation 0x000000010836f7e8 IBCTTRunProcessingRequestsPopulatingResults
 27. IBCocoaTouchToolFoundation 0x000000010836fbd0 __IBCTTProduceResultForSceneUpdateRequest_block_invoke_2
 28. IBCocoaTouchToolFoundation 0x00000001083760e0 -[IBCTTUISimulatedMetricsContext applyGlobalAndAdditionalSimulatedMetricsForTool:during:]
 29. IBCocoaTouchToolFoundation 0x000000010836f3fe IBCTTProduceResultForSceneUpdateRequest
 30. IBCocoaTouchToolFoundation 0x000000010833b326 -[IBCocoaTouchTool updateScenesWithSceneUpdateRequests:]
 31. AssetCatalogFoundation   0x00000001086877e1 __80-[IBMessageReceiveChannel deliverMessage:toTarget:withArguments:context:result:]_block_invoke
 32. AssetCatalogFoundation   0x000000010868767e -[IBMessageReceiveChannel deliverMessage:toTarget:withArguments:context:result:]
 33. AssetCatalogFoundation   0x000000010868710e __88-[IBMessageReceiveChannel runBlockingReceiveLoopNotifyingQueue:notifyingTarget:context:]_block_invoke
 34. libdispatch.dylib        0x00007fff20115b25 _dispatch_client_callout
 35. libdispatch.dylib        0x00007fff20123de6 _dispatch_async_and_wait_invoke
 36. libdispatch.dylib        0x00007fff20115b25 _dispatch_client_callout
 37. libdispatch.dylib        0x00007fff20123043 _dispatch_main_queue_drain
 38. libdispatch.dylib        0x00007fff20122c1b _dispatch_main_queue_callback_4CF
 39. CoreFoundation           0x00007fff20373261 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
 40. CoreFoundation           0x00007fff2036da56 __CFRunLoopRun
 41. CoreFoundation           0x00007fff2036ca90 CFRunLoopRunSpecific
 42. Foundation               0x00007fff20827e31 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
 43. AssetCatalogFoundation   0x000000010865a5de -[IBAbstractPlatformTool startServingReceiveChannel:]
 44. AssetCatalogFoundation   0x000000010865a829 -[IBAbstractPlatformTool startServingWriteDescriptor:readDescriptor:]
 45. AssetCatalogFoundation   0x000000010865b544 +[IBAbstractPlatformTool main]
 46. IBAgent-iOS              0x0000000107e16983 main
 47. ???                      0x0000000108030f21 ???
 48. ???                      0x0000000111a9a51e [DVTFoundation.UIKitForMacInfo init]
Exception info:{
}




=================================
    EXCEPTION:
=================================

*** -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array

我可能错了,但错误似乎与我的收集视图有关。我将视图放入集合视图而不是堆栈视图中,然后出现了此错误。有人可以帮助我了解错误以及如何解决吗?先感谢您!

I have a problem with my 'Main.storyboard' file. I am using Xcode 13.3.1. Here is an image of the Interface Builder:

enter image description here

As you can see, one of the view controllers is only showing the bounds of its subviews.

Here is the 'Log.txt' file that I got when I clicked on 'Report a Bug':

    ASSERTION:
=================================

Failed to update scene 'WYl-z5-IOU' with IBLayoutConstraint (x181), IBUIViewAutolayoutGuide (x1), UIButton (x12), UICollectionView (x3), UICollectionViewCell (x3), UICollectionViewFlowLayout (x3), UIImageView (x8), UILabel (x20), UIPageControl (x1), UIScrollView (x1), UIStackView (x10), UITextField (x1), UIView (x18), and UIViewController (x1).

Exception name: NSRangeException
Exception reason: *** -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array
Exception backtrace: 
  0. CoreFoundation           0x00007fff20406d34 __exceptionPreprocess
  1. libobjc.A.dylib          0x00007fff201a4a65 objc_exception_throw
  2. CoreFoundation           0x00007fff20487f47 _CFThrowFormattedException
  3. CoreFoundation           0x00007fff203016b2 -[__NSArrayM objectAtIndexedSubscript:]
  4. UIKitCore                0x00007fff247448bc -[_UIFlowLayoutSection computeLayoutInRect:forSection:invalidating:invalidationContext:]
  5. UIKitCore                0x00007fff24728a75 __76-[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:]_block_invoke
  6. CoreFoundation           0x00007fff2037682c __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__
  7. CoreFoundation           0x00007fff203009c6 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:]
  8. UIKitCore                0x00007fff2472871d -[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:]
  9. UIKitCore                0x00007fff24728cee -[UICollectionViewFlowLayout _fetchItemsInfoForRect:]
 10. UIKitCore                0x00007fff24721950 -[UICollectionViewFlowLayout prepareLayout]
 11. UIKitCore                0x00007fff2471b450 -[UICollectionViewData _prepareToLoadData]
 12. UIKitCore                0x00007fff2471c2b5 -[UICollectionViewData validateLayoutInRect:]
 13. UIKitCore                0x00007fff246db9f1 -[UICollectionView layoutSubviews]
 14. UIKitCore                0x00007fff2565a2b0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
 15. QuartzCore               0x00007fff28a6639d _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE
 16. UIKitCore                0x00007fff256457fa -[UIView(Hierarchy) layoutBelowIfNeeded]
 17. IBCocoaTouchToolFoundation 0x000000010832fa2d -[IBCocoaTouchToolAutolayoutEngine layoutIfNeeded]
 18. IBAutolayoutFoundation   0x000000010847f736 __54-[IBAutolayoutEngine initWithArbitrationUnit:options:]_block_invoke.46
 19. CoreAutoLayout           0x00007fff60b03f05 -[NSISEngine performModifications:withUnsatisfiableConstraintsHandler:]
 20. IBAutolayoutFoundation   0x000000010848df03 -[NSObject(IBAutolayoutFrameworkSupportInternal) ib_performModifications:withUnsatisfiableConstraintsHandler:]
 21. IBAutolayoutFoundation   0x000000010847fbc8 -[IBAutolayoutEngine performInternalEngineModificationsAndAssertOnUnsatisfiableConstraintsIfNeededDuring:withUnsatisfiableConstraintsHandler:]
 22. IBAutolayoutFoundation   0x0000000108483915 -[IBAutolayoutEngine continuouslyPerformEngineBootstrappingOperationWithName:untilSuccessWhileTrackingUnsatisfiableConstraintsDuring:withUnsatisfiableConstraintRemovedHandler:]
 23. IBAutolayoutFoundation   0x000000010847f58b -[IBAutolayoutEngine initWithArbitrationUnit:options:]
 24. IBAutolayoutFoundation   0x000000010846eb72 -[IBAutolayoutArbitrationUnit computeStatus]
 25. IBCocoaTouchToolFoundation 0x000000010834cdb0 -[IBAutolayoutStatusProcessingRequest(IBCTTSupport) produceResultForRequest:simulatedMetricsContext:scaleFactor:tool:]
 26. IBCocoaTouchToolFoundation 0x000000010836f7e8 IBCTTRunProcessingRequestsPopulatingResults
 27. IBCocoaTouchToolFoundation 0x000000010836fbd0 __IBCTTProduceResultForSceneUpdateRequest_block_invoke_2
 28. IBCocoaTouchToolFoundation 0x00000001083760e0 -[IBCTTUISimulatedMetricsContext applyGlobalAndAdditionalSimulatedMetricsForTool:during:]
 29. IBCocoaTouchToolFoundation 0x000000010836f3fe IBCTTProduceResultForSceneUpdateRequest
 30. IBCocoaTouchToolFoundation 0x000000010833b326 -[IBCocoaTouchTool updateScenesWithSceneUpdateRequests:]
 31. AssetCatalogFoundation   0x00000001086877e1 __80-[IBMessageReceiveChannel deliverMessage:toTarget:withArguments:context:result:]_block_invoke
 32. AssetCatalogFoundation   0x000000010868767e -[IBMessageReceiveChannel deliverMessage:toTarget:withArguments:context:result:]
 33. AssetCatalogFoundation   0x000000010868710e __88-[IBMessageReceiveChannel runBlockingReceiveLoopNotifyingQueue:notifyingTarget:context:]_block_invoke
 34. libdispatch.dylib        0x00007fff20115b25 _dispatch_client_callout
 35. libdispatch.dylib        0x00007fff20123de6 _dispatch_async_and_wait_invoke
 36. libdispatch.dylib        0x00007fff20115b25 _dispatch_client_callout
 37. libdispatch.dylib        0x00007fff20123043 _dispatch_main_queue_drain
 38. libdispatch.dylib        0x00007fff20122c1b _dispatch_main_queue_callback_4CF
 39. CoreFoundation           0x00007fff20373261 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
 40. CoreFoundation           0x00007fff2036da56 __CFRunLoopRun
 41. CoreFoundation           0x00007fff2036ca90 CFRunLoopRunSpecific
 42. Foundation               0x00007fff20827e31 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
 43. AssetCatalogFoundation   0x000000010865a5de -[IBAbstractPlatformTool startServingReceiveChannel:]
 44. AssetCatalogFoundation   0x000000010865a829 -[IBAbstractPlatformTool startServingWriteDescriptor:readDescriptor:]
 45. AssetCatalogFoundation   0x000000010865b544 +[IBAbstractPlatformTool main]
 46. IBAgent-iOS              0x0000000107e16983 main
 47. ???                      0x0000000108030f21 ???
 48. ???                      0x0000000111a9a51e [DVTFoundation.UIKitForMacInfo init]
Exception info:{
}




=================================
    EXCEPTION:
=================================

*** -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array

I may be wrong but the error seems to be related to my collection views. I dropped a view into a collection view rather than a stack view and then this error came. Can someone help me understand the error and how to fix it? Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄情伤 2025-02-03 21:46:34

好吧,我尝试创建一个新的收集视图,并且奏效了!我知道那很乏味,所以请继续回答。谢谢。

Well, I tried creating a new collection view and it worked! I know that's tedious so please continue answering. Thank you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文