我将苹果付款实施到我的应用中。当我点击苹果支付按钮时,会出现标准支付弹出视图控制器。为了解雇它,我可以按下取消按钮,但我也希望能够通过单击超级视图来关闭弹出视图。
func alertClose(gesture: UITapGestureRecognizer) {
self.dismiss(animated: true, completion: nil)
print("It is working")
}
@IBAction func PayApple(_ sender: Any) {
let paymentViewController = PKPaymentAuthorizationViewController(paymentRequest: request)
paymentViewController.delegate = self
self.present(paymentViewController, animated: true, completion: {
paymentViewController.view.superview?.isUserInteractionEnabled = true
paymentViewController.view.superview?.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.alertClose(gesture:))))
})
}
但我上面实施的内容并不奏效。我不确定我做错了什么。当我点击超级视图时,苹果支付弹出不会消失。