我遇到以下問題。我在Appdelegate中創建了一個UIButton,並且我希望該按鈕能夠導航到另一個ViewController。我已經與Storyboard建立了連接,這個連接是一個Modal Segue類型的連接。我認爲performSegueWithIdentifier會做這項工作,但它給了我以下錯誤「沒有標識符showCamera'的繼續」。而且我很確定我已經通過故事板製作了標識符。從Appdelegate通過UIButton導航到另一個視圖
let camera = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
camera.addTarget(self, action: "takePicture:", forControlEvents: .TouchUpInside);
//this function works
func takePicture(sender: UIButton!){
println("Open Camera")
//this throws an error
self.window?.rootViewController?.performSegueWithIdentifier("showCamera", sender: self)
}
如果有人能幫助我,這將是非常gratefull。
爲什麼從AppDelegate初始化? – 2015-03-25 09:09:03
你有什麼建議? @ Dato'MohammadNurdin 我在UITabbar中做了一個自定義按鈕,所以我可以謹慎地調用UIPickerController。我必須在appdelegate中創建該按鈕,因爲我的tabbar已在那裏初始化。如果您有任何其他建議,那麼會更受歡迎。 – Navid 2015-03-25 09:18:35