我正在嘗試一種簡單的註銷功能,其中視圖在用戶註銷後返回到我的登錄/註冊視圖。我曾嘗試使用這兩種方法,但每次應用程序崩潰。解析註銷功能
第一種方法:
@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標識,而不是視圖本身的名稱。目標視圖標識爲空 –