[英]Having issues in xcode 6.1 throws exception error
I am completely new here! 我是这里的新手! Learning by the seat of my pants.
在我的裤子旁学习。 Trying to create a login and Password screen with a label.
尝试创建带有标签的登录和密码屏幕。 I have a textfield for User Name, one for Password, a label that says "Please Login" and a button to push.
我有一个用于用户名的文本字段,一个用于密码的文本字段,上面写着“请登录”的标签和一个按下按钮。 Everything is fine until I get to the button.
一切正常,直到我按下按钮。 I drag the button to the screen and set it up how I want, but when I try to command left click drag the button to the code, I get no options to make it an action.
我将按钮拖动到屏幕上并按照自己的需要进行设置,但是当我尝试命令左键单击时,将按钮拖动到代码上,则没有任何选择可以使它动作。
So it comes in as @IBOutlet var theButton: UIView! 因此它以@IBOutlet var theButton:UIView的形式出现! which is wrong.
这是错误的。 The only options I get is Outlet and Outlet Collections, I can type over UIView and make it UIButton.
我获得的唯一选项是“ Outlet”和“ Outlet Collections”,我可以在UIView上键入并使它成为UIButton。
So I manually type in : 所以我手动输入:
@IBAction func theButton(sender: AnyObject) {
var usr = "debf"
var pw = "cando"
if theTextfieldUsername.text == usr && theTextfieldPassword.text == pw {
println("Login Sucessful")
theTextfieldUsername.resignFirstResponder()
theTextfieldPassword.resignFirstResponder()
}
else {
println("Login Not Sucessful. Please Signup")
theTextfieldUsername.resignFirstResponder()
theTextfieldPassword.resignFirstResponder()
}
}
And when I run it, it throws and exception and I can not figure out what the problem is! 而当我运行它时,它会抛出异常,并且我无法弄清楚问题出在哪里! I get:
我得到:
2014-10-24 17:45:23.096 UFMTest[4146:1713077] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UFMTest.ViewController 0x79c70990> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key theSubmitButt.'
theSubmitButt
was the name of the button the first time I made it, I've deleted it and redone it several times but I still get this. theSubmitButt
是我第一次创建按钮时的名称,我已将其删除并重做了几次,但还是可以得到。
Any suggestions? 有什么建议么?
Here is the entire code: 这是完整的代码:
//
// ViewController.swift
// UFMTest
//
// Created by Deborah Flack on 10/24/14.
// Copyright (c) 2014 Armidido Inc. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet var theTextfieldUsername: UITextField!
@IBOutlet var theTextfieldPassword: UITextField!
@IBOutlet var theLabel: UILabel!
@IBAction func theButton(sender: AnyObject) {
var usr = "debf"
var pw = "cando"
if theTextfieldUsername.text == usr && theTextfieldPassword.text == pw {
println("Login Sucessful")
theTextfieldUsername.resignFirstResponder()
theTextfieldPassword.resignFirstResponder()
}
else {
println("Login Not Sucessful. Please Signup")
theTextfieldUsername.resignFirstResponder()
theTextfieldPassword.resignFirstResponder()
}
}
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.
}
The problem is, even after you deleted theSubmitButt
code from from ViewController
, Storyboard is still trying to connect the button to theSubmitButt
. 问题是,即使从
ViewController
删除了theSubmitButt
代码,Storyboard仍在尝试将按钮连接到theSubmitButt
。
To resolve that, check "Connection Inspector" out in Interface Builder, and disconnect it from theSubmitButt
by clicking x
button. 若要解决此问题,请在Interface Builder中检查“ Connection Inspector”,然后通过单击
x
按钮将其与theSubmitButt
断开连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.