【发布时间】:2015-06-26 22:44:49
【问题描述】:
从图库中选择照片后,我正在尝试打开下一个 viewController。我可以从图库中获取图像,但之后我不知道如何打开它旁边的控制器。 !.This is photo of that storyboard
【问题讨论】:
标签: ios iphone swift ios7 ios8
从图库中选择照片后,我正在尝试打开下一个 viewController。我可以从图库中获取图像,但之后我不知道如何打开它旁边的控制器。 !.This is photo of that storyboard
【问题讨论】:
标签: ios iphone swift ios7 ios8
您可以使用 Interface Builder 或在代码中(如您所愿)将 UITapGestureRecognizer 放入您的 UIImageView 中,我更喜欢第一个。您可以在您的UIImageView 中放置一个@IBAction 并处理水龙头,不要忘记在Interface Builder 或代码中将UserInteractionEnabled 设置为true。
要显示下一个视图控制器,您可以使用下面的代码或仅使用 Interface Builder 通过您之前设置的UITapGestureRecognizer 进行转场(由您决定)。
要像下面的代码那样手动显示视图控制器,您需要为视图控制器设置 Storyboard ID,如下图所示(在 Identity Inspector 面板中 ):
@IBAction func imageTapped(sender: AnyObject) {
// Set the storyboard name by default is Main
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
// Instantiate the ViewController with the name you set before like in the image
let nextViewController = storyboard.instantiateViewControllerWithIdentifier("ViewControllerB") as! UIViewController
// present the nextViewController
self.presentViewController(nextViewController, animated: true, completion: nil)
}
希望对你有所帮助。
【讨论】: