解决[UITapGestureRecognizer tag]: unrecognized selector sent to instance

// 这样写就会崩溃

addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(cancel)))

@objc private func cancel() {

    }

// 这样写就不会崩溃

addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(cancel(_:))))

@objc private func cancel(_ gesture: UITapGestureRecognizer) {

    }

你可能感兴趣的:(解决[UITapGestureRecognizer tag]: unrecognized selector sent to instance)