我的问题是我如何才能运行代码并在完成后让segue开火?
这是我到目前为止:
@IBAction func onlogoutClick(sender: AnyObject) { //clear all url chache NSURLCache.sharedURLCache().removeAllCachedResponses() //null out everything for logout email = "" password = "" self.logininformation.setobject(self.email,forKey: "email") self.logininformation.setobject(self.password,forKey: "password") self.logininformation.synchronize() //self.vIEw = LoginVIEw}解决方法 你有几个选择;
第一种是从IB中的按钮中删除动作,然后在UIVIEwController对象和下一个场景之间创建一个segue;
@IBAction func onlogoutClick(sender: AnyObject) { //clear all url chache NSURLCache.sharedURLCache().removeAllCachedResponses() //null out everything for logout email = "" password = "" self.logininformation.setobject(self.email,forKey: "password") self.logininformation.synchronize() self.performSegueWithIDentifIEr("logoutSegue",sender: self)}
或者你可以摆脱@IBAction方法并实现prepareForSegueWithIDentifIEr
overrIDe func prepareForSegue(segue: UIStoryboardSegue!,sender: AnyObject!) { if segue.IDentifIEr == "logoutSegue" { //clear all url chache NSURLCache.sharedURLCache().removeAllCachedResponses() //null out everything for logout email = "" password = "" self.logininformation.setobject(self.email,forKey: "email") self.logininformation.setobject(self.password,forKey: "password") self.logininformation.synchronize() }}总结
以上是内存溢出为你收集整理的ios – 在swift中按下按钮后,在segue之前执行一些代码全部内容,希望文章能够帮你解决ios – 在swift中按下按钮后,在segue之前执行一些代码所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)