应用程序在视图控制器中添加@IBAction时崩溃

时间:2018-04-16 06:12:40

标签: ios swift toolbar xcode9

我试图在UITableView的底部添加一个工具栏,它是>成功添加。但是当我用IBAction连接条形按钮时,  在加载该视图控制器应用程序时崩溃。没有链接  到IbAction应用程序工作正常。

我正在使用xCode 9.2

这是我的故事板。

enter image description here

enter image description here

这是崩溃日志。

   2018-04-11 11:11:38.636121+0500 SafeBolt[9610:88848] *** Assertion failure in -[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.33.6/_UINavigationBarVisualProviderModernIOS.m:569
    2018-04-11 11:11:38.662356+0500 SafeBolt[9610:88848] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Sigh. Contentview size is zero.'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x00000001072b612b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x00000001063fdf41 objc_exception_throw + 48
        2   CoreFoundation                      0x00000001072bb2f2 +[NSException raise:format:arguments:] + 98
        3   Foundation                          0x0000000105e9ed69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
        4   UIKit                               0x00000001085d22f5 -[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight] + 265
        5   UIKit                               0x00000001083505e0 -[UINavigationItem _desiredHeightForBarMetrics:defaultHeightBlock:] + 90
        6   UIKit                               0x00000001085d4fa1 -[_UINavigationBarVisualProviderModernIOS heightRangeFittingWidth:] + 412
        7   UIKit                               0x0000000107ae40ed -[UINavigationBar _heightRangeForNavigationItem:fittingWidth:] + 210
        8   UIKit                               0x0000000107bc0a98 -[UINavigationController _intrinsicNavigationBarHeightRangeForViewController:] + 187
        9   UIKit                               0x0000000107bc09b6 -[UINavigationController _preferredHeightForHidingNavigationBarForViewController:] + 628
        10  UIKit                               0x0000000107bb088f -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 356
        11  UIKit                               0x0000000107bb0cf8 -[UINavigationController _positionNavigationBarHidden:edge:] + 388
        12  UIKit                               0x0000000107bb8555 -[UINavigationController loadView] + 243
        13  UIKit                               0x0000000107b7b05c -[UIViewController loadViewIfRequired] + 195
        14  UIKit                               0x0000000107b7b8b9 -[UIViewController view] + 27
        15  iOS_Slide_Menu                      0x00000001054bbe5a -[SlideNavigationController setEnableShadow:] + 74
        16  iOS_Slide_Menu                      0x00000001054b9804 -[SlideNavigationController setup] + 244
        17  iOS_Slide_Menu                      0x00000001054b9541 -[SlideNavigationController initWithCoder:] + 145
        18  UIKit                               0x0000000107e644c8 -[UIClassSwapper initWithCoder:] + 246
        19  UIKit                               0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
        20  UIKit                               0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
        21  UIKit                               0x0000000107ae075a -[UINavigationBar initWithCoder:] + 753
        22  UIKit                               0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
        23  UIKit                               0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
        24  UIKit                               0x000000010834b5f2 -[UINavigationItem initWithCoder:] + 1018
        25  UIKit                               0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
        26  UIKit                               0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
        27  UIKit                               0x0000000107b76053 -[UIViewController initWithCoder:] + 432
        28  SafeBolt                            0x000000010448dfa2 _T08SafeBolt18BaseViewControllerCACSgSo7NSCoderC5coder_tcfc + 66
        29  SafeBolt                            0x000000010446db83 _T08SafeBolt26EmailListingViewControllerCACSgSo7NSCoderC5coder_tcfc + 1315
        30  SafeBolt                            0x000000010446dc4f _T08SafeBolt26EmailListingViewControllerCACSgSo7NSCoderC5coder_tcfcTo + 47
        31  UIKit                               0x0000000107e644c8 -[UIClassSwapper initWithCoder:] + 246
        32  UIKit                               0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
        33  UIKit                               0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
        34  UIKit                               0x0000000107e64194 -[UIRuntimeConnection initWithCoder:] + 178
        35  UIKit                               0x0000000107e648d0 -[UIRuntimeEventConnection initWithCoder:] + 59
        36  UIKit                               0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
        37  UIKit                               0x00000001080b92a7 UINibDecoderDecodeObjectForValue + 1118
        38  UIKit                               0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
        39  UIKit                               0x0000000107e63391 -[UINib instantiateWithOwner:options:] + 1262
        40  UIKit                               0x00000001082f3fc2 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
        41  SafeBolt                            0x000000010448eda2 _T08SafeBolt11AppDelegateC23setUpRootViewControlleryyF + 386
        42  SafeBolt                            0x000000010448f6b5 _T08SafeBolt11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tF + 101
        43  SafeBolt                            0x000000010448f79a _T08SafeBolt11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tFTo + 186
        44  UIKit                               0x00000001079cabca -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 299
        45  UIKit                               0x00000001079cc648 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4113
        46  UIKit                               0x00000001079d1aeb -[UIApplication _runWithMainScene:transitionContext:completion:] + 1720
        47  UIKit                               0x0000000107d9b6f8 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 924
        48  UIKit                               0x00000001081714c8 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
        49  UIKit                               0x0000000107d9b2f1 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 249
        50  UIKit                               0x0000000107d9bb6b -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 696
        51  UIKit                               0x0000000108719a69 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 262
        52  UIKit                               0x0000000108719922 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 444
        53  UIKit                               0x00000001083f69c8 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 221
        54  UIKit                               0x00000001085f5b06 _performActionsWithDelayForTransitionContext + 100
        55  UIKit                               0x00000001083f688b -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 231
        56  UIKit                               0x0000000108170b25 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
        57  UIKit                               0x00000001079d036a -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 523
        58  UIKit                               0x0000000107fab605 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 369
        59  FrontBoardServices                  0x000000010d340cc0 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 338
        60  FrontBoardServices                  0x000000010d3497b5 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 235
        61  libdispatch.dylib                   0x000000010af5933d _dispatch_client_callout + 8
        62  libdispatch.dylib                   0x000000010af5e9f3 _dispatch_block_invoke_direct + 592
        63  FrontBoardServices                  0x000000010d375498 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
        64  FrontBoardServices                  0x000000010d37514e -[FBSSerialQueue _performNext] + 464
        65  FrontBoardServices                  0x000000010d3756bd -[FBSSerialQueue _performNextFromRunLoopSource] + 45
        66  CoreFoundation                      0x0000000107259101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        67  CoreFoundation                      0x00000001072f8f71 __CFRunLoopDoSource0 + 81
        68  CoreFoundation                      0x000000010723da19 __CFRunLoopDoSources0 + 185
        69  CoreFoundation                      0x000000010723cfff __CFRunLoopRun + 1279
        70  CoreFoundation                      0x000000010723c889 CFRunLoopRunSpecific + 409
        71  GraphicsServices                    0x000000010dcb79c6 GSEventRunModal + 62
        72  UIKit                               0x00000001079d35d6 UIApplicationMain + 159
        73  SafeBolt                            0x0000000104490d27 main + 55
        74  libdyld.dylib                       0x000000010afd5d81 start + 1
    )
    libc++abi.dylib: terminating with uncaught exception of type NSException
    (lldb)

以下是IbAction的代码。

@IBAction func testAction(_ sender: UIBarButtonItem) {

    }

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:-1)

请尝试以下步骤以解决此问题。如果它对您不起作用,也请告诉我。

  
      
  1. 选择要添加IBAction的故事板中的项目
  2.   
  3. 检查连接检查器,看看是否还有一些额外的连接,而不是所需的连接。
  4.   
  5. 如果还有其他额外连接,请删除它们并再次编译代码。它应该工作。
  6.   

当您创建连接并从控制器中删除代码但您的连接仍然存在时,通常会发生此错误。