class VIEwController: UIVIEwController {@IBOutlet weak var imageVIEw: UIImageVIEw!overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // create tap gesture recognizer let tapGesture = UITapGestureRecognizer(target: self,action: "imageTapped:") // add it to the image vIEw; imageVIEw.addGestureRecognizer(tapGesture) // make sure imageVIEw can be interacted with by user imageVIEw.userInteractionEnabled = true}func imageTapped(gesture: UIGestureRecognizer) { // if the tapped vIEw is a UIImageVIEw then set it to imagevIEw if let imageVIEw = gesture.vIEw as? UIImageVIEw { println("Image Tapped") //Here you can initiate your new VIEwController } }}
Swift 3.0
class VIEwController: UIVIEwController { @IBOutlet weak var imageVIEw: UIImageVIEw! overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // create tap gesture recognizer let tapGesture = UITapGestureRecognizer(target: self,action: #selector(VIEwController.imageTapped(gesture:))) // add it to the image vIEw; imageVIEw.addGestureRecognizer(tapGesture) // make sure imageVIEw can be interacted with by user imageVIEw.isUserInteractionEnabled = true } func imageTapped(gesture: UIGestureRecognizer) { // if the tapped vIEw is a UIImageVIEw then set it to imagevIEw if (gesture.vIEw as? UIImageVIEw) != nil { print("Image Tapped") //Here you can initiate your new VIEwController } }}总结
以上是内存溢出为你收集整理的ios – 如何在故事板上单击UIImageView(swift)全部内容,希望文章能够帮你解决ios – 如何在故事板上单击UIImageView(swift)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)