0
我正在使用IAPHelper实现应用内购买,当按下购买按钮后转到其他视图控制器时发生错误。例如,当我按购买按钮,然后转到另一个视图控制器,完成购买工作后出现错误。应用内购买Swift
class selectQuestion_ViewController: UITableViewController, UITableViewDelegate, UITableViewDataSource{
let helper = IAPHelper(productIdentifiers: NSSet(object: "sppid") as Set<NSObject>)
func purchase(sender: AnyObject)
{
startLoading("Purchasing ..")
self.helper.requestProductsWithCompletionHandler({ (success, products) -> Void in
if success {
self.endLoading()
println("wohooooo")
var sdad = self.helper.productsDict["sppid"]
self.helper.buyProduct(sdad!)
} else {
self.endLoading()
let alert = UIAlertController(title: "Error", message: "Cannot retrieve products list right now.", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
})
}
虽然此链接可能回答这个问题,最好在这里包含答案的重要部分,并提供参考链接ENCE。如果链接页面更改,则仅链接答案可能会失效。 - [来自评论](/ review/low-quality-posts/10400514) – Calimero
真的,让我这样做。 – 2015-12-01 13:22:01