![ios – 在ViewDidLoad中执行Segue [复制],第1张 ios – 在ViewDidLoad中执行Segue [复制],第1张](/aiimages/ios+%E2%80%93+%E5%9C%A8ViewDidLoad%E4%B8%AD%E6%89%A7%E8%A1%8CSegue+%5B%E5%A4%8D%E5%88%B6%5D.png)
我试图在第一次加载应用程序时执行segue.
我可以在调试器中看到我的打印消息,但Perform Segue不起作用.我没有得到任何错误.
有人可以告诉我什么错了吗?
import UIKitimport LocalAuthenticationlet isFirstLaunch = UserDefaults.isFirstLaunch()extension UserDefaults { // check for is first launch - only true on first invocation after app install,false on all further invocations // Note: Store this value in AppDelegate if you have multiple places where you are checking for this flag static func isFirstLaunch() -> Bool { let hasBeenLaunchedBeforeFlag = "hasBeenLaunchedBeforeFlag" let isFirstLaunch = !UserDefaults.standard.bool(forKey: hasBeenLaunchedBeforeFlag) if (isFirstLaunch) { UserDefaults.standard.set(true,forKey: hasBeenLaunchedBeforeFlag) UserDefaults.standard.synchronize() } return isFirstLaunch }}class loginVC: UIVIEwController { overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() if isFirstLaunch == false { performSegue(withIDentifIEr: "setPassword",sender: self) print("testFalse") } else { performSegue(withIDentifIEr: "setPassword",sender: self) print("testTrue")} // Do any additional setup after loading the vIEw,typically from a nib. }解决方法 您不能在vIEwDIDLoad()中使用performSegue().将其移至vIEwDIDAppear(). 在vIEwDIDLoad()时,当前视图甚至没有附加到窗口,因此不可能进行segue.
总结以上是内存溢出为你收集整理的ios – 在ViewDidLoad中执行Segue [复制]全部内容,希望文章能够帮你解决ios – 在ViewDidLoad中执行Segue [复制]所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)