iOS 10及更早版本上出现“Could not instantiate class named _UIScrollViewLayoutGuide”的应用程序崩溃问题

6

我一直遇到以下错误,而现有的 Stack Overflow 答案都没有帮助到我。我很难通过查看控制台结果来确定错误的确切位置。

在旧设备上运行时,我会得到这样的错误(在新设备上正常工作)。我应该尝试哪些方法来确定问题所在?

2019-12-30 16:52:04.784 Hospital[7075:164758] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named _UIScrollViewLayoutGuide'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010ad9fb0b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010a804141 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010ae08625 +[NSException raise:format:] + 197

    3   UIKit                               0x000000010c15368d UINibDecoderDecodeObjectForValue + 323

    4   UIKit                               0x000000010c15353f -[UINibDecoder decodeObjectForKey:] + 89
    5   Foundation                          0x0000000109b0e417 -[NSLayoutConstraint initWithCoder:] + 757
    6   UIKit                               0x000000010c1537ff UINibDecoderDecodeObjectForValue + 693

    7   UIKit                               0x000000010c15399d UINibDecoderDecodeObjectForValue + 1107

    8   UIKit                               0x000000010c15353f -[UINibDecoder decodeObjectForKey:] + 89
    9   UIKit                               0x000000010bbee9de -[UIView initWithCoder:] + 2209
    10  UIKit                               0x000000010bc29687 -[UIScrollView initWithCoder:] + 71
    11  UIKit                               0x000000010c1537ff UINibDecoderDecodeObjectForValue + 693
    12  UIKit                               0x000000010c15399d UINibDecoderDecodeObjectForValue + 1107
    13  UIKit                               0x000000010c15353f -[UINibDecoder decodeObjectForKey:] + 89
    14  UIKit                               0x000000010bbee4ed -[UIView initWithCoder:] + 944
    15  UIKit                               0x000000010c1537ff UINibDecoderDecodeObjectForValue + 693

    16  UIKit                               0x000000010c15353f -[UINibDecoder decodeObjectForKey:] + 89
    17  UIKit                               0x000000010bf62f70 -[UIRuntimeConnection initWithCoder:] + 178
    18  UIKit                               0x000000010c1537ff UINibDecoderDecodeObjectForValue + 693
    19  UIKit                               0x000000010c15399d UINibDecoderDecodeObjectForValue + 1107
    20  UIKit                               0x000000010c15353f -[UINibDecoder a:] + 89
    21  UIKit                               0x000000010bf6216d -[UINib instantiateWithOwner:options:] + 1262
    22  UIKit                               0x000000010bcfcfc3 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
    23  UIKit                               0x000000010bcfd8d9 -[UIViewController loadView] + 177
    24  UIKit                               0x000000010bcfdc0a -[UIViewController loadViewIfRequired] + 195
    25  UIKit                               0x000000010bcfe45a -[UIViewController view] + 27
    26  Hospital                     0x00000001086ecb00 $s15_Hospital15PagerScrollViewC03setcdE010toParentVC05pagesI0ySo16UIViewControllerC_SayAHGSgtF + 1152
    27  Hospital                     0x00000001086f6b85 $s15_Hospital22HomeMainViewControllerC11viewDidLoadyyF + 3861
    28   Hospital                     0x00000001086f6e9b $s15_Hospital22HomeMainViewControllerC11viewDidLoadyyFTo + 43
    29  UIKit                               0x000000010bcfe01a -[UIViewController loadViewIfRequired] + 1235
    30  UIKit                               0x000000010bd3ce6c -[UINavigationController _layoutViewController:] + 56
    31  UIKit                               0x000000010bd3d74a -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 466
    32  UIKit                               0x000000010bd3d8bb -[UINavigationController _startTransition:fromViewController:toViewController:] + 127
    33  UIKit                               0x000000010bd3ea03 -[UINavigationController _startDeferredTransitionIfNeeded:] + 843
    34  UIKit                               0x000000010bd3fb41 -[UINavigationController __viewWillLayoutSubviews] + 58
    35  UIKit                               0x000000010bf3160c -[UILayoutContainerView layoutSubviews] + 231
    36  UIKit                               0x000000010bc1e55b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
    37  QuartzCore                          0x000000010a572904 -[CALayer layoutSublayers] + 146
    38  QuartzCore                          0x000000010a566526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
    39  QuartzCore                          0x000000010a5663a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    40  QuartzCore                          0x000000010a4f5e92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    41  QuartzCore                          0x000000010a522130 _ZN2CA11Transaction6commitEv + 468
    42  QuartzCore                          0x000000010a522b37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
    43  CoreFoundation                      0x000000010ad45717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23

    44  CoreFoundation                      0x000000010ad45687 __CFRunLoopDoObservers + 391
    45  CoreFoundation                      0x000000010ad2a038 CFRunLoopRunSpecific + 440
    46  UIKit                               0x000000010bb5508f -[UIApplication _run] + 468
    47  UIKit                               0x000000010bb5b134 UIApplicationMain + 159
    48   Hospital                     0x000000010872773b main + 75
    49  libdyld.dylib                       0x000000010e5d965d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

似乎Xcode 11.2中存在一个错误导致了这个问题。 - The Pedestrian
如果您正在使用相同的版本,请尝试更新到Xcode 11.2.1。 - The Pedestrian
我目前正在使用Xcode 11.3。 - Jaseel.Dev
3个回答

10

我遇到了同样的问题(使用 Xcode11 并运行 iOS 10.3.1)。 在滚动视图中取消选中“内容布局指南”对我有用。

图片


我的已经取消选中了。所以,我勾选它然后再取消选中,问题就解决了。 - Brainware

3
感谢@Luke的回答,我找到了问题的确切原因:它是由任何项目和滚动视图的内容布局指南之间的约束引起的。
因此,要找出问题所在,需要:
  1. 检查日志,找出哪个视图控制器参与了该问题。根据@Jaseel.Dev所显示的日志,它是“Alexis_Hospital”
  2. 在那个视图控制器中,在界面构建器中检查所有滚动视图及其内容布局指南或框架布局指南
  3. 有两种方法可以修复:

a) 单击滚动视图,在那里取消选中[ ] 内容布局指南并重新选中它们(接口生成器将重新将“布局指南”边缘分配给“超级视图”)

enter image description here

b) 点击“内容自动布局指南”,查看是否有指向它们的任何约束。摆脱这些约束。

enter image description here

主要想法是消除这些限制,这些限制会在iOS 10及更早版本上崩溃。

0

请在您的源代码中检查以下内容:

  1. 检查您的Xib或Storyboard文件是否有IBOutlet或IBAction连接警告。
  2. 看起来错误应该在您的Xib或Storyboard中,因为错误日志回溯显示UINibDecoder中的错误。
  3. UILayoutGuide从iOS 9.0+开始提供,因此请检查您的应用程序的部署目标,应为iOS 9或更高版本。
  4. 另外,您已经提到您只在旧设备上看到了这个问题,这些设备可能运行的iOS版本低于9。
  5. 在Xcode的文件检查器中取消选中“使用安全区域布局指南”选项。
  6. 最后,请检查您之前工作的源代码版本,并将最近的更改与错误代码库进行比较,以确定崩溃原因。

旧设备出现问题,其iOS版本为10.3。 - Jaseel.Dev
抱歉,这个不起作用。不管怎样,感谢您宝贵的时间。 - Jaseel.Dev

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接