在viewDidLoad中初始化tapRecognizer应该可以做到,因为您在初始化视图之前就将自己定位为
class ViewController: UIViewController, MFMailComposeViewControllerDelegate { @IBOutlet weak var tokenDisplay: UILabel! var tapGestureRecognizer:UITapGestureRecognizer! override func viewDidLoad() { super.viewDidLoad() tapGestureRecognizer = UITapGestureRecognizer(target:self, action: #selector(onUserClickingSendToken(_:))) tapGestureRecognizer.numberOfTapsRequired = 1 tokenDisplay.isUserInteractionEnabled = true tokenDisplay.addGestureRecognizer(tapGestureRecognizer) } func onUserClickingSendToken(_ sender: Any) { ....