[英]Navigate from UIView to UIViewController without storyboard and navigation controller
[英]How to navigate to another UIView controller (previously created in storyboard) by pressing an image
我在当前的故事板上创建了一个图像,然后向其添加了轻按手势,因此,一旦点击它,我就知道了。 然后,我在故事板上创建了另一个UIView控制器,该控制器连接到名为“ DetailedUIViewController.swift”的cocatoch类。 现在,我想在单击图像后移至该视图。
这是我的形象:
@IBOutlet weak var totalEnergy: UIImageView!
这是我的点击手势定义:
let TGTE = UITapGestureRecognizer(target: self, action: #selector(totalEnergyFunc))
totalEnergy.isUserInteractionEnabled = true
TGTE.numberOfTapsRequired = 1
totalEnergy.addGestureRecognizer(TGTE)
这是单击图像后调用的函数:
func totalEnergyFunc(){
}
现在,我要获取的是如何转到调用函数后先前创建的第二个视图?
确保您具有DetailedUIViewController
的storyboard ID
按Command + Option + 3并为DetailedUIViewController
设置storyboard ID
在totalEnergyFunc
方法中显示DetailedUIViewController
func totalEnergyFunc(){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "someViewController")
self.present(controller, animated: true, completion: nil)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.