向UIStackView添加轻击手势 [英] Add tap gesture to UIStackView

查看:72
本文介绍了向UIStackView添加轻击手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将 UITapGesture 添加到collectionView单元格中的 UIStackView 中,但是每次我执行应用程序时都会崩溃.(所有 IBOutlets 都已连接)这是我在做错什么吗?

Im attempting to add a UITapGesture to a UIStackView within a collectionView cell but each time I do my app crashes. (All IBOutlets are connected) This there something I'm doing wrong here?

 let fGuesture = UITapGestureRecognizer(target: self, action: #selector(self.showF(_:)))
 cell.fstackView.addGestureRecognizer(fGuesture)

 func showF(sender: AnyObject){
        print(111)
    }

推荐答案

堆栈视图是否启用了触摸功能?尝试设置Userinteraction参数

Is the stackview enabled for touch ? Try to set Userinteraction Parameter

cell.fstackView.isUserInteractionEnabled = true 

这篇关于向UIStackView添加轻击手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆