【发布时间】:2015-03-25 08:40:21
【问题描述】:
我有以下问题。我在我的 Appdelegate 中创建了一个 UIButton,我希望该按钮将我导航到另一个 ViewController。我已经从我的 Storyboard 中建立了一个连接,这个连接是 Modal Segue 类型。我认为 performSegueWithIdentifier 可以完成这项工作,但它给了我以下错误“没有带有标识符'showCamera'的segue”。而且我很确定我已经通过情节提要制作了该标识符。
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)
}
【问题讨论】:
-
为什么从 AppDelegate 初始化?
-
你有什么建议? @Dato'MohammadNurdin 我在我的 UITabbar 中制作了一个自定义按钮,因此我可以谨慎地调用 UIPickerController。我必须在 appdelegate 中创建该按钮,因为我的标签栏已在那里初始化。如果您有任何其他更受欢迎的建议。
标签: ios iphone swift uibutton uistoryboardsegue