Я сделал ярлык и использовал tapgesturerecogniser, чтобы он работал на кране.Но когда я нажимаю на ярлык, он не работает, однако ярлык отображается просто отлично.Я добавляю их в виде прокрутки.
Ниже мой код:
tryLabel.translatesAutoresizingMaskIntoConstraints = false
tryLabel.textColor = .white
tryLabel.text = "tryLabel"
tryLabel.textAlignment = .left
tryLabel.isUserInteractionEnabled = true
let tapGesture = UITapGestureRecognizer.init(target: self, action: #selector(dateAddedTapped))
tapGesture.numberOfTapsRequired = 1
tapGesture.isEnabled = true
tryLabel.gestureRecognizerShouldBegin(tapGesture)
editInfoView.addSubview(tryLabel)
tryLabel.leftAnchor.constraint(equalTo: editInfoView.leftAnchor, constant: 310).isActive = true
tryLabel.topAnchor.constraint(equalTo: editInfoView.topAnchor, constant: 150).isActive = true
tryLabel.widthAnchor.constraint(equalToConstant: 300).isActive = true
tryLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true
@objc func dateAddedTapped(){print(" Date added ")}