ios - 按下按钮时应用程序崩溃

标签 ios swift xcode6

这就是正在发生的事情,我的 Storyboard 中有两个场景,场景一是登录表单,场景二是调用 NSURLSession 的表单(不过该场景不是问题所在)

发生的事情是,当我在第一个场景中单击“登录”按钮时,应用程序崩溃了,应该发生的是应该根据(当前硬编码的)用户凭据检查登录凭据,如果它们正确,应该进行 segue将用户发送到第二个场景。

这是错误日志数据;

2014-10-01 17:24:51.454 TotalSMSAPP[15443:446622] -[TotalSMSAPP.ViewController1 activateLogin:]: unrecognized selector sent to instance 0x7f88d3424620 2014-10-01 17:24:51.459 TotalSMSAPP[15443:446622] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TotalSMSAPP.ViewController1 activateLogin:]: unrecognized selector sent to instance 0x7f88d3424620'

这是适用于问题场景的代码;

import Foundation
import UIKit

class ViewController1: UIViewController {

    @IBOutlet var username: UITextField!
    @IBOutlet var password: UITextField!


    @IBAction func login(sender: UIButton) {
        if(username.text == "koharu" && password.text == "test"){
            self.performSegueWithIdentifier("toSMS",sender: self)
        }else{


        }
    }

}

最佳答案

'NSInvalidArgumentException',原因:'-[TotalSMSAPP.ViewController1 activateLogin:]:无法识别的选择器发送到实例 0x7f88d3424620'

此错误表明在您定义 login: 时调用了 activateLogin:。如果您重命名该方法,则可能会发生这种情况。删除按钮操作并使用 @IBAction func login(sender: UIButton) 重新连接它。

关于ios - 按下按钮时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26138213/

相关文章:

ios - sublayerTransform 的动画持续时间被忽略

html - 我正在尝试将 html 字符串加载到 webview 中。但是 WebView 在运行时显示白色空白

objective-c - 在 ios xcode 4.3( Storyboard)中弹出 facebook 提要对话框(用于墙贴)

ios - swift/iOS : Collapsing a section in a UITableView

ios - 如何在 Storyboard 中设置导航栏的标题?

ios - swift - UIAlertController 将用户带回到第一个 ViewController

ios - 在另一个闭包中调用一个swift闭包导致的栈溢出

ios - swift - firebase facebook 身份验证时出现 invalid_credentials 错误?

ios - swift/parse getObjectInBackgroundWithId 查询不起作用

objective-c - Xcode6:IBDesignable 和 IBInspectable 与 Objective-C