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冲突,但我不知道为什么