我正面临一个错误,表示在Xcode中发现未捕获的异常(信号SIGABRT)[重复]

问题描述 投票:-1回答:4

我只是在点击按钮时尝试打印。

import UIKit

class ViewController: UIViewController {

    @IBAction func bu(_ sender: UIButton) {
        print("click")
    }

}

它在控制台中显示错误

2017-05-22 18:28:58.751它会工作[24356:1074948] *由于未捕获的异常'NSUnknownKeyException'终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不符合键值编码钥匙扣。' *第一次抛出调用堆栈:(0 CoreFoundation 0x0000000110a06b0b exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010ddcb141 objc_exception_throw + 48 2 CoreFoundation 0x0000000110a06a59 - [NSException raise] + 9 3 Foundation 0x000000010d8e0e8b - [NSObject(NSKeyValueCoding)setValue:forKey:] + 292 4 UIKit 0x000000010e431644 - [UIViewController setValue:forKey:] + 87 5 UIKit 0x000000010e69e6b9 - [UIRuntimeOutletConnection connect] + 109 6 CoreFoundation 0x00000001109ace8d - [NSArray makeObjectsPerformSelector:] + 269 7 UIKit 0x000000010e69d06f - [UINib instantiateWithOwner:options:] + 1856 8 UIKit 0x000000010e437c73 - [UIViewController _loadViewFromNibNamed:bundle:] + 381 9 UIKit 0x000000010e438589 - [UIViewController loadView] + 177 10 UIKit 0x000000010e4388ba - [UIViewController loadViewIfRequired] + 195 11 UIKit 0x000000010e43910a - [UIViewController视图] + 27 12 UIKit 0x000000010e30163a - [UIWindow addRootViewControllerViewIfPossible] + 65 13 UIKit 0x000000010e301d20 - [UIWindow _setHidden:forced:] + 294 14 UIKit 0x000000010e314b6e - [UIWindow makeKeyAndVisible] + 42 15 UIKit 0x000000010e28e31f - [UIApplication的_callInitializationDelegatesForMainScene:transitionContext:] + 4346 16的UIKit 0x000000010e294584 - [UIApplication的_runWithMainScene:transitionContext:完成:] + 1709 17的UIKit 0x000000010e291793 - [UIApplication的workspaceDidEndTransaction:] + 182个18 FrontBoardServices 0x00000001121065f6 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24个19 FrontBoardServices 0x000000011210646d - [FBSSerialQueue _performNext ] + 186个20 FrontBoardServices 0x00000001121067f6 - [FBSSerialQueue _performNextFromRunLoopSource] + 45 21的CoreFoundation 0x00000001109acc01 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 22的CoreFoundation 0x00000001109920cf __CFRunLoopDoSources0 + 527 23的CoreFoundation 0x00000001109915ff __CFRunLoopRun + 911 24的CoreFoundation 0x0000000110991016 CFRunLoopRunSpecific + 406 25 UIKit 0x000000010e29002f - [UIApplication _run] + 468 26 UIKit 0x000000010e2960d4 UIApplicationMain + 159 27会起作用吗 0x000000010d638c17 main + 55 28 libdyld.dylib 0x000000011199665d start + 1)libc ++ abi.dylib:以NSException类型的未捕获异常终止(lldb)

我认为这里的按钮连接不是图像:

ios xcode swift3 xcode8 uncaught-exception
4个回答
1
投票

@Narasimha Reddy请从故事板上断开按钮插座。

enter image description here


0
投票

请从故事板上断开按钮插座。


0
投票

如果你可以在没有连接视图的情况下运行而且没有异常,那就出错了。当UIViewController加载并尝试显示它时,它使用视图来知道要显示的内容。仔细检查您的课程和联系。如果您没有发现问题,请发布更多信息,我们会尽力解决。


0
投票

最重要的信息是

'[setValue:forUndefinedKey:]:这个类不是键值按键编码兼容的。“

看看你的代码只有一个动作bu而不是button,这很可能是一个错字。

所以更换

@IBAction func bu(_ sender: UIButton)

@IBAction func button(_ sender: UIButton)
© www.soinside.com 2019 - 2024. All rights reserved.