Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UILable上面的UILABLEVIEW,UILable不能触摸,为什么?_Ios_Uitableview_Uilabel - Fatal编程技术网

Ios UILable上面的UILABLEVIEW,UILable不能触摸,为什么?

Ios UILable上面的UILABLEVIEW,UILable不能触摸,为什么?,ios,uitableview,uilabel,Ios,Uitableview,Uilabel,UITableVIew上方有一个uitable,uitable和UITableVIew是兄弟,我在uitable中添加了手势识别器,但是这个手势无法触发,为什么?请确保设置为userInteractionEnabled为true 在您的视图中加载 YOUR_Label.isUserInteractionEnabled = true let tap = UITapGestureRecognizer(target: self, action: #selector(self.uilab


UITableVIew上方有一个uitable,uitable和UITableVIew是兄弟,我在uitable中添加了手势识别器,但是这个手势无法触发,为什么?

请确保设置为userInteractionEnabled为true

在您的视图中加载

    YOUR_Label.isUserInteractionEnabled = true
    let tap = UITapGestureRecognizer(target: self, action: #selector(self.uilabelTapped(_:)))
    YOUR_Label.addGestureRecognizer(tap)
在您的ViewController中

@objc func uilabelTapped(_ sender: UITapGestureRecognizer) {
    print("UILabel Tapped")
}
确保tableView和uilabel是同一视图的子视图


希望这将对您有所帮助

您是否将标签的
userInteractionEnabled
属性设置为
true
?是否将userInteractionEnabled设置为true@Andr埃斯洛塔,谢谢你的帮助,我已经将userInteractionEnabled设置为true,我猜interaction设置为uitable冲突,interaction设置为tableView,但我不知道why@AneeshG,感谢您的帮助,我已将userInteractionEnabled设置为true@mrX感谢您的帮助,我已经将userInteractionEnabled设置为true,我猜interaction to UIABLE与interaction to tableView冲突,但我不知道为什么