我正在尝试一种简单的注销功能,其中视图在用户注销后返回到我的登录/注册视图。我曾尝试使用这两种方法,但每次应用程序崩溃。解析注销功能
第一种方法:
@IBAction func signPressed(sender: AnyObject) {
PFUser.logOut()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("ViewController") as! UIViewController
presentViewController(vc, animated: true, completion: nil)
}
第二种方法:
我创建了以下功能:
func loginSetup() {
if (PFUser.currentUser() == nil) {
let vc = ViewController()
self.presentViewController(vc, animated: true, completion: nil)
}
}
然后将其添加到我的登出功能:
@IBAction func signPressed(sender: AnyObject) {
PFUser.logOut()
self.loginSetup()
}
都崩溃了,给了我一个应用程序委托错误..这里的问题是什么?
这里是给出错误的截图:
https://40.media.tumblr.com/1f044ecbdd5059836b0a360d16af9846/tumblr_nqzsobll0o1tupbydo1_1280.png
有什么错误信息呢?您的信息不足以帮助我们。 –
这完全没有帮助,控制台上是否印有任何内容? –
不,控制台上没有任何东西,事实证明该方法是调用视图控制器storyboard标识,而不是视图本身的名称。目标视图标识为空 –