Swift 3 - 线程 1 : Signal SIGABRT Unrecognised selector sent to Instance

标签 swift xcode

有谁能帮我解决这个问题吗?我已经尝试解决这个问题几个小时了,但到目前为止还没有任何效果。每次我单击按钮时,它都会立即导致错误“线程 1:信号 SIGABRT”。

这是代码(注意:它仍在进行中):

import UIKit
class ViewController: UIViewController {
@IBOutlet var Sec1: UILabel!
@IBOutlet var Sec2: UILabel!
@IBOutlet var Sec3: UILabel!
@IBOutlet var Sec4: UILabel!
@IBOutlet var Sec5: UILabel!
@IBOutlet var Sec6: UILabel!
@IBOutlet var Sec7: UILabel!
@IBOutlet var Sec8: UILabel!
@IBOutlet var Sec9: UILabel!


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
var x = 2
   // if (x%2 == 0) {
    @IBAction func ButtonPressed(Button1: UIButton) {
   Sec1.text = "X"
    }    
}

这是错误:

**2017-02-23 07:58:14.194 Tic Tac Toe IS[46707:2457511] -[Tic_Tac_Toe_IS.ViewController ButtonPressed:]: unrecognized selector sent to instance 0x7fb8a8d04ee0
2017-02-23 07:58:14.202 Tic Tac Toe IS[46707:2457511] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Tic_Tac_Toe_IS.ViewController ButtonPressed:]: unrecognized selector sent to instance 0x7fb8a8d04ee0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010bebfd4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00000001092be21e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010bf2ff04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x000000010be45005 ___forwarding___ + 1013
    4   CoreFoundation                      0x000000010be44b88 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000010978f8bc -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKit                               0x0000000109915c38 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x0000000109915f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
    8   UIKit                               0x0000000109914e4d -[UIControl touchesEnded:withEvent:] + 668
    9   UIKit                               0x00000001097fd545 -[UIWindow _sendTouchesForEvent:] + 2747
    10  UIKit                               0x00000001097fec33 -[UIWindow sendEvent:] + 4011
    11  UIKit                               0x00000001097ab9ab -[UIApplication sendEvent:] + 371
    12  UIKit                               0x0000000109f9872d __dispatchPreprocessedEventFromEventQueue + 3248
    13  UIKit                               0x0000000109f91463 __handleEventQueue + 4879
    14  CoreFoundation                      0x000000010be64761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x000000010be4998c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x000000010be48e76 __CFRunLoopRun + 918
    17  CoreFoundation                      0x000000010be48884 CFRunLoopRunSpecific + 420
    18  GraphicsServices                    0x000000010ddf9a6f GSEventRunModal + 161
    19  UIKit                               0x000000010978dc68 UIApplicationMain + 159
    20  Tic Tac Toe IS                      0x0000000108cdb7af main + 111
    21  libdyld.dylib                       0x000000010ce6f68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)** 

最佳答案

您能检查一下 @IBAction 函数 ButtonPressed() 与 Storyboard之间的连接吗?您可以从 Storyboard 上的“连接检查器”进行检查。

关于Swift 3 - 线程 1 : Signal SIGABRT Unrecognised selector sent to Instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42405355/

相关文章:

ios - 如何暂停函数的执行,直到完成 block 被执行?

ios - 快速获取 iPhone 语言

ios - 在 iOS 的条形图中显示整数值标签

html - 以编程方式按 NSURLRequest 中的 html 按钮

iphone - Xcode iPhone 加速计图像

swift - 无法将类型 'Data' 的值转换为指定类型 'Data'

swift - 如何检索满足条件 swift 2 的 CoreData

ios - 加载新网址时我会丢失历史记录

xcode - swift 框架

ios - 除了 UITableViewController 之外,还有什么方法可以在 UIViewController 中使用原型(prototype)单元吗?