最近スウィフトを学び始めました。プログラムは以前は正常に動作していましたが、私は何をしたのか分からず、今は動きません。ボタンが表示されず、1つの画面でクラッシュします。エラー:「キャッチされていない例外「NSUnknownKeyExeption」の理由でアプリケーションを終了しています、理由:[setValue:forUndefinedKey:]:このクラスはキーnextButtonに対応するキー値ではありません。アイブ氏は、次の画面に移動するにはボタンをクリックしましたが、私はそれをクリックすると、それはHomeViewController、SecondScreenViewController、およびThirdScreenViewControllerにHERESにコードをクラッシュスウィフト3で画面の表示を変更
HomeViewController
@IBAction func notifiyButtonPressed(_ sender: AnyObject) {
print("Pressed")
self.performSegue(withIdentifier: "ViewSegue", sender: self)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
print("View has loaded! ")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
SecondScreenViewController:。。
@IBOutlet var textField: UITextField!
@IBAction func nextButtonPressed(_ sender: Any) {
self.performSegue(withIdentifier: "whotoclass", sender: self)
}
override func viewDidLoad() {
super.viewDidLoad()
self.textField.delegate = self
print("View 2 Loaded")
// 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.
}
//Hide Keyboard when user touches outside keybaord
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
//Presses return key
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return(true)
}
ThirdScreenViewController:
import UIKit
クラスThirdScreenViewController:のUIViewController {
@IBOutlet var joshClassButton: UIButton!
@IBAction func joshClassButton(_ sender: Any) {
self.performSegue(withIdentifier: "classtoperiod", sender: self)
}
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.
}
また取り付けは私Main.storyboardの画像です。少なくとも2時間問題に取り組んでいるので、誰もがここで助けてくれると大規模な助けになるでしょう。みんな、ありがとう!
http://i.imgur.com/QCuJojA.png
スウィフト3のためにこれを試してくださいもちろんnextButtonというプロパティはありません。クラスを設定しなかった場合は、2番目のVCから 'nextButton'コンセントを削除する必要があります。 – NRitH
スタックトレースのスクリーンショット(例外の上のログの出力)を含めてください。 私の直感は、ストーリーボードから離れて走るように伝えることです。それは長期的にあなたを制限する悪いツールです。それを使用するように設定されている場合は、スタックトレースを含めてください。できることがわかります。 – Ryan
ねえねえ。助けてくれてありがとう。私は周りをうんざりして自分で修正しました。私はそれを削除したが、コードにまだ残っていた。再度、感謝します! –