【问题标题】:Xcode 8: Terminating with Uncaught exception of type NSExceptionXcode 8:以 NSException 类型的未捕获异常终止
【发布时间】:2017-02-21 16:28:13
【问题描述】:

我是新手,遇到此错误,我到处查找,但找不到解决方案。任何帮助将不胜感激!

  0   CoreFoundation                      0x00000001102bb34b __exceptionPreprocess + 171
  1   libobjc.A.dylib                     0x000000010d61c21e objc_exception_throw + 48
  2   CoreFoundation                      0x00000001102bb299 -[NSException raise] + 9
  3   Foundation                          0x000000010d12c2ff -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
  4   UIKit                               0x000000010dbafc01 -[UIView(CALayerDelegate) setValue:forKey:] + 173
  5   UIKit                               0x000000010def9be6 -[UIRuntimeOutletConnection connect] + 109
  6   CoreFoundation                      0x0000000110260590 -[NSArray makeObjectsPerformSelector:] + 256
  7   UIKit                               0x000000010def856a -[UINib instantiateWithOwner:options:] + 1867
  8   UIKit                               0x000000010dc451e8 -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 399
  9   UIKit                               0x000000010dc456e0 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 71
  10  Foodtracker                         0x000000010d0274e7 _TFC11Foodtracker23MealTableViewController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 199
  11  Foodtracker                         0x000000010d027a97 _TToFC11Foodtracker23MealTableViewController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 87
  12  UIKit                               0x000000010dc58ba9 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 757
  13  UIKit                               0x000000010dc58e07 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
  14  UIKit                               0x000000010dc2c871 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3295
  15  UIKit                               0x000000010dc62189 -[UITableView _performWithCachedTraitCollection:] + 110
  16  UIKit                               0x000000010dc489e3 -[UITableView layoutSubviews] + 222
  17  UIKit                               0x000000010dbb0344 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
  18  QuartzCore                          0x000000011306acdc -[CALayer layoutSublayers] + 146
  19  QuartzCore                          0x000000011305e7a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
  20  QuartzCore                          0x000000011305e61e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
  21  QuartzCore                          0x0000000112fec62c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
  22  QuartzCore                          0x0000000113019713 _ZN2CA11Transaction6commitEv + 475
  23  QuartzCore                          0x000000011301a083 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
  24  CoreFoundation                      0x000000011025fe17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
  25  CoreFoundation                      0x000000011025fd87 __CFRunLoopDoObservers + 391
  26  CoreFoundation                      0x00000001102444b6 CFRunLoopRunSpecific + 454
  27  UIKit                               0x000000010dae5db6 -[UIApplication _run] + 434
  28  UIKit                               0x000000010daebf34 UIApplicationMain + 159
  29  Foodtracker                         0x000000010d028c4f main + 111
  30  libdyld.dylib                       0x00000001111e568d start + 1
  31  ???                                 0x0000000000000001 0x0 + 1

) libc++abi.dylib:以 NSException 类型的未捕获异常终止 (lldb)

【问题讨论】:

  • 你想做什么?我只能推断,在 dequeueReusableCellWithIdentifier:forIndexPath: 方法中,您返回的是一些 Cell,您之前必须在其中拥有某些属性,但您删除了该属性。
  • 你是否开启了objective-c异常断点?如果没有,请打开它们,当发生此类崩溃时,您将被带到发生这种情况的线路。
  • 它把我带到了这条线:class AppDelegate: UIResponder, UIApplicationDelegate {

标签: ios swift xcode8


【解决方案1】:

检查您的故事板:所有连接的 IBAction、IBOutlet 以及它们当前的名称?它实际上是在 iboutlets 出现问题时发生的

【讨论】:

  • 尝试断开并重新连接它们。这样做只是为我解决了这个崩溃问题。
【解决方案2】:

如果您刚刚更新到 Swift 4 并且在 iOS 11 设备或模拟器上运行您的应用程序时遇到了问题,那么您可能遇到了与 UIVisualEffectView 相同的问题,特别是在添加子视图时它。

Apple's documentation 说:

将子视图添加到 contentView 而不是 UIVisualEffectView 直接。

基本上,不是直接将子视图添加到UIVisualEffectView,而是将它们添加到其.contentView

例子:

// create UIVisualEffectView
let blackBlur = UIVisualEffectView(effect: UIBlurEffect(style: .dark))

// adding a subview - this worked on iOS 10 - crashes the app on iOS 11
blackBlur.addSubview(someView)

// this works on both iOS 10 and iOS 11
blackBlur.contentView.addSubview(someView)

我希望这对某人有所帮助,因为我花了一段时间才弄清楚这一点。

【讨论】:

    【解决方案3】:

    如果有人遇到这个问题,请确保您

    1. 转到 Main.storyboard
    2. 右键单击手机轮廓顶部的黄色框图标(视图控制器)
    3. 删除带有黄色标志的插座。

    在这种情况下,您可能会命名一个动作,然后重命名它。您需要删除旧名称,如果这是唯一的问题将在模拟器中启动!

    注意:大多数情况下发生这种情况是因为连接错误,因此请仔细检查并确保所有插座连接正确。

    【讨论】:

      【解决方案4】:

      提升方法是setValue:forKey:,在一个table view cell出队后调用。 显然在 MealTableViewController 中。

      检查您的表格视图单元格 XIB,可能存在一个名称错误的 IBOutlet,或者可能是一个名称错误的属性集。

      【讨论】:

        【解决方案5】:

        如果您使用 Firebase 并在上传时遇到此问题,请注意键值。键不应包含“#”或“%”等。我刚刚删除并正常工作。

        【讨论】:

        • 对不起,我在这里漏掉了一些东西,你上面指的是哪个键?
        • 已经有一段时间了。很可能我的意思是密钥的名称不应包含这些字符。
        猜你喜欢
        • 1970-01-01
        • 2014-07-26
        • 2016-03-25
        • 1970-01-01
        • 2017-07-25
        • 1970-01-01
        • 1970-01-01
        • 2013-07-20
        相关资源
        最近更新 更多