我在我的應用程序中有兩個視圖。主視圖(ViewController.swift)和側邊欄(SideBar.swift)。如果我點擊側邊欄中的按鈕,應該顯示一個UIAlertView
(我在ViewController.swift中調用一個函數)。但該應用程序崩潰,因爲主視圖是零。你知道我該如何解決這個問題嗎?目前主視圖控制器中的警報視圖(從子類中調用)
我在功能(顯示警告)代碼:
let alertView = UIAlertController(title: "You need to log in first", message: "To access the special features of the app you need to log in first.", preferredStyle: .Alert)
alertView.addAction(UIAlertAction(title: "Login", style: .Default, handler: { (alertAction) -> Void in
}))
alertView.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
self.presentViewController(alertView, animated: true, completion: nil)
崩潰日誌:
0x724160 <+60>: bl 0x75961c ; function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded> of Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) ->()).(closure #2)
-> 0x724164 <+64>: trap
你有沒有在側邊欄類參考ViewController.swift? – Robert