gpt4 book ai didi

ios - 尝试在...上呈现...其 View 不在窗口层次结构中

转载 作者:行者123 更新时间:2023-11-30 10:52:14 26 4
gpt4 key购买 nike

当付款已正确处理时,我正在尝试执行“成功窗口”的连接。我正在尝试使用以下方法来做到这一点:

self.performSegue(withIdentifier: "successView", sender: self)

在我的 addCardViewController 函数中。 (如下所示:)

    func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreateToken token: STPToken, completion: @escaping STPErrorBlock) {

// Monetary amounts on stripe are based on the lowest monetary unit (i.e. cents),
// therefore, we need to multiply the dollar amount by 100 to get the correct amount.
let stripeAmount = toPay * 100

// Call the 'stripeCharge' Firebase cloud function, with user's card token and amount
functions.httpsCallable("stripeCharge").call(["token": token.tokenId, "amount": String(stripeAmount)]) { (result, error) in
if let error = error {
print("Error: \(error)")
}

// Get the charge id after successful payment
var chargeId: String
if let data = result?.data as? [String: Any] {
chargeId = data["chargeId"] as? String ?? "no id"
print("Charge id: \(chargeId)")

//send new info

//show successfull payment view with charge

//self.present(self.successViewController, animated: true, completion: nil)
self.performSegue(withIdentifier: "successView", sender: self)
}

completion(nil)
//self.performSegue(withIdentifier: "successView", sender: self)
}

}

但我不断收到错误“尝试在......其 View 不在窗口层次结构中呈现......”

有谁知道这是为什么吗?这是 main.storyboard 的图片 here is a picture of the main.storyboard

最佳答案

可能你不在主线程上?通常网络调用的回调函数是在主线程之外的。除非您确定这不是问题,否则请尝试添加它:

DispatchQueue.main.async {
self.performSegue(withIdentifier: "successView", sender: self)
}

关于ios - 尝试在...上呈现...其 View 不在窗口层次结构中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54334808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com