iOS通过SKStoreProductViewController 在app中直接访问app store 不需要跳转到app store
首先 import StoreKit
StoreKit 中的 SKStoreProductViewController是app store提供的方法
官方文档
A SKStoreProductViewController object presents a store that allows the user to purchase other media from the App Store. For example, your app might display the store to allow the user to purchase another app.
添加代理 SKStoreProductViewControllerDelegate
import StoreKit.SKStoreProductViewController
//访问代码段
func showStore(id:Int) {
let storeViewController = SKStoreProductViewController()
storeViewController.delegate = self
let parameters = [SKStoreProductParameterITunesItemIdentifier :
NSNumber(integer: id)]
storeViewController.loadProductWithParameters(parameters,
completionBlock: {result, error in
if result {
self.presentViewController(storeViewController,
animated: true, completion: nil)
// remove loading animation
}
})
}
//结束访问代码段
func productViewControllerDidFinish(viewController: SKStoreProductViewController) {
viewController.dismissViewControllerAnimated(true, completion: nil)
self.bottomToolbar.hidden = false
}