当我从另一个 class 调用时发送到实例的无法识别的选择器

unrecognized selector sent to instance when i call from another class

当我从另一个 class 调用识别器时出现此错误: 无法识别的选择器发送到实例, 如果你在同一个 class

中调用没有错误
var orderViewCard = OrderVC()

let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(orderViewCard.handleCardTap(recognzier:)))
orderViewCard.handleArea.addGestureRecognizer(tapGestureRecognizer)

在 OrderVC 中:

@objc
    func handleCardTap(recognzier:UITapGestureRecognizer) {
        switch recognzier.state {
        case .ended:
            animateTransitionIfNeeded(state: nextState, duration: 0.9)
        default:
            break
        }
}

您需要做的是select相应地定位

     var orderViewCard = OrderVC()

    let tapGestureRecognizer = UITapGestureRecognizer(target: orderViewCard, action: #selector(orderViewCard.handleCardTap))
    orderViewCard.handleArea.addGestureRecognizer(tapGestureRecognizer)