我从登录VIEw Controller到新的导航控制器有一个模态segue.
我已经尝试过几乎所有我遇到过的建议,似乎没有任何工作.使用Sift和Xcode 6.
import UIKitimport AudioToolBoxclass VIEwController: UIVIEwController { @IBOutlet weak var usernameTextFIEld: UITextFIEld! @IBOutlet weak var passwordTextFIEld: UITextFIEld! @IBOutlet weak var incorrectCredentialLabel: UILabel! @IBAction func loginAction(sender: UIbutton) { var username = "test" var password = "code" println("Username: " + usernameTextFIEld.text) println("Password: " + passwordTextFIEld.text) if usernameTextFIEld.text == username && passwordTextFIEld.text == password { usernameTextFIEld.resignFirstResponder() passwordTextFIEld.resignFirstResponder() println("Login Status: success") self.shouldPerformSegueWithIDentifIEr("loginSegue",sender: nil) } else { usernameTextFIEld.resignFirstResponder() passwordTextFIEld.resignFirstResponder() AudioServicesPlayAlertSound(1352) /*AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)*/ incorrectCredentialLabel.text = "username or password is incorrect" incorrectCredentialLabel.textcolor = UIcolor.redcolor() println("Login Status: Failed") }} 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. }}解决方法 这对我有用.两个UITextFIElds和一个UIbutton以及从VC到VC2的模态segue:
import UIKitclass VIEwController: UIVIEwController,UITextFIEldDelegate { let username = "John" let passCode = "123" @IBOutlet weak var name: UITextFIEld! @IBOutlet weak var Pass: UITextFIEld! @IBAction func tapbutton(sender: UIbutton) { if self.name.text == "John" && self.Pass.text == "123" { performSegueWithIDentifIEr("nextVIEw",sender: self) } } //VIEwController lifecycle overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() self.name.delegate = self self.Pass.delegate = self }}总结
以上是内存溢出为你收集整理的快速定制segue条件全部内容,希望文章能够帮你解决快速定制segue条件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)