当我点击UIView但手势不起作用时。

override func viewDidLoad() {
        super.viewDidLoad()

        let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
        viewForSHadow.isUserInteractionEnabled = true
        viewForSHadow.addGestureRecognizer(tap)

        // Do any additional setup after loading the view.
    }


func handleTap(_sender: UITapGestureRecognizer) {
        print("---------View Tapped--------")
        viewForSHadow.isHidden = true
        viewForAlert.isHidden = true
    }


我只想在UIView点击上执行此操作。

最佳答案

如果 alpha = 0的任何内容与您的 viewForSHadow 重叠,则可以检查调试视图层次结构

10-08 07:23