按下保存按钮后,我试图进入下一个屏幕,我尝试编写代码执行segue,但出现了很多错误。下面是我的当前代码,我还没有完成保存部分。我想回到那以后。
我是xcode编码的新手,因此任何建议将此代码放在何处都是不错的选择。
import UIKit
import CoreData
class SignupVC: UIViewController {
@IBOutlet var txtfirstname: UITextField!
@IBOutlet var txtlastname: UITextField!
@IBOutlet var txtUsername: UITextField!
@IBOutlet var txtPassword: UITextField!
@IBOutlet var txtConfirmpassword: UITextField!
@IBOutlet var txtEmail: UITextField!
var context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func signupTapped(_ sender: Any) {
_ = txtUsername.text;
_ = txtPassword.text;
_ = txtConfirmpassword.text;
_ = txtEmail.text;
//check empty fields
if((txtPassword.text?.isEmpty)! || (txtConfirmpassword.text?.isEmpty)! || (txtEmail.text?.isEmpty)!)
{
//Display alert
displayMyAlertMessage(userMessage: "All fields are required")
return;
}
//check if passwords match
if (txtPassword.text != txtConfirmpassword.text)
{
//Display in alert message
displayMyAlertMessage(userMessage: "Passwords don't match");
return;
}
//store Data
// Display alert message with Confirmation
}
func displayMyAlertMessage(userMessage:String)
{
let myAlert = UIAlertController(title:"Alert", message: userMessage, preferredStyle: UIAlertControllerStyle.alert);
let okAction = UIAlertAction(title:"ok", style: UIAlertActionStyle.default, handler:nil);
myAlert.addAction(okAction);
self.present(myAlert, animated:true, completion:nil);
}
/*
答案 0 :(得分:0)
只需进入情节提要并按住按钮上的控制键,然后将其放到要转到的ViewController上即可。然后选择种类。例如“显示”
然后它应该工作。如果您有任何疑问,请问。