使用StoreKit时,Apple UIAlertController完成

时间:2015-10-12 10:09:01

标签: ios swift storekit uialertcontroller

我正在实施付款ViewController,我想在StoreKit提取一些数据时提供加载视图(微调器)。
我在"购买"时添加了加载视图。单击按钮,并在调用func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse)时将其删除。问题是loading"登录iTunes Store" (其中)仍然显示。
我有没有办法获得/覆盖Apple生成的UIAlertControllers的完成块?
任何想法将不胜感激!!

1 个答案:

答案 0 :(得分:0)

我建议使用MKStoreKit吗?

我遇到了StoreKit的问题,但是使用MKStoreKit转到了这样的代码。

let notification = NSNotificationCenter.defaultCenter()
func purchase() {
    MKStoreKit.sharedKit().initiatePaymentRequestForProductWithIdentifier("YOURIDENTIFIER")
    self.notification.addObserverForName(kMKStoreKitProductPurchaseFailedNotification, object: nil, queue: NSOperationQueue()) {
        (note) -> Void in
        // It failed for some reason
        self.hideLoadingView() 
    }

    self.notification.addObserverForName(kMKStoreKitProductPurchasedNotification, object: nil, queue: NSOperationQueue()) {
        (note) -> Void in
        // It was purchased
        self.hideLoadingView() 
    }

    self.notification.addObserverForName(kMKStoreKitProductPurchaseDeferredNotification, object: nil, queue: NSOperationQueue()) {
        (note) -> Void in
        // It was canceled 
        self.hideLoadingView()         
    }
}

func hideLoadingView() {
    // Do whatever you need to
}

让事情变得更容易管理